ASP.NET母版页DefaultButton覆盖 [英] ASP.NET Master page DefaultButton override

查看:172
本文介绍了ASP.NET母版页DefaultButton覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单元素并设置一个服务器端的ImageButton的defaultbutton属性的母版页。在我的网页之一,我想覆盖在Page_Load事件中设置窗体DefaultButton母版defaultbutton属性。

I have a master page with a form element and the defaultbutton attribute set to a server-side ImageButton. On one of my pages I want to "override" the masterpage defaultbutton attribute by setting the Forms DefaultButton in the Page_Load event.


在母校页:

i.e On mater page:

<form id="form1" runat="server" defaultbutton="btnSearch">....</from>

在该页面的Page_Load事件覆盖母版页属性:

On the page Page_Load event that "override" the master page attribute:

this.Form.DefaultButton = this.ibRecalc.ID;

它有错误:

Form1的的defaultButton必须类型IButtonControl的控件的ID

The DefaultButton of 'form1' must be the ID of a control of type IButtonControl

我使用图像按钮它实现IButtonControl

I am using image buttons which implements IButtonControl

什么,我可能是做错了任何想法或以不同的方式来解决这个问题?

Any ideas of what I might be doing wrong or a different way to approach the problem?

感谢

推荐答案

使用唯一ID。既然你可以有多个服务器控件使用相同的服务器ID,即在一个GridView,框架需要的唯一ID匹配到。

Use UniqueId. Since you can have multiple server controls with the same server id, ie, in a GridView, the framework needs to the unique id to match up to.

this.Form.DefaultButton = this.ibRecalc.UniqueID;

这篇关于ASP.NET母版页DefaultButton覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆