呈现页面时如何区分HTML Button和Server Button. [英] How to differentiate between HTML Button and Server Button when page is rendered .

查看:148
本文介绍了呈现页面时如何区分HTML Button和Server Button.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如何在呈现页面时查找哪个控件是HTML和Server.因为呈现页面时我们仅获得控件的HTML,所以没有runat = server.因此如何找到此事件是由Asp Button触发的,请帮帮我.

设计时的代码

Hi,


How to find which control is HTML and Server when page is rendered.Because when page is rendered we get only HTML for a control there no runat=server.So how will find that this event was fired by Asp Button.please help me out.

Code at design Time

<asp:Button ID="btnLogin" runat="server" Text="Login" onclick="btnLogin_Click"  />
            <asp:Button ID="btnPrint" runat="server" Text="Print" 
             Height="29px"  
            style="font-weight: 700" Width="70px" onclick="btnPrint_Click" />
        <asp:Button ID="Button1" runat="server" onclientclick="javascript:get();" 
            Text="Button" onclick="Button1_Click" />
        <input id="htmlButton" type="button" value="button" /><input id="btnHtmlSubmit" 
            type="submit" value="submit" />



呈现页面时

<输入类型=提交" name ="btnLogin" value =登录" id ="btnLogin"/>
< input type ="submit" name ="btnPrint" value ="Print" id ="btnPrint" style ="height:29px; width:70px; font-weight:700"/>
< input type ="submit" name ="Button1" value ="Button"önclick="javascript:get();" id ="Button1"/>
< input id ="htmlButton" type ="button" value ="button"/>< input id ="btnHtmlSubmit"
type ="submit" value =提交"/>



When page is rendered

<input type="submit" name="btnLogin" value="Login" id="btnLogin" />
<input type="submit" name="btnPrint" value="Print" id="btnPrint" style="height:29px;width:70px;font-weight: 700" />
<input type="submit" name="Button1" value="Button" önclick="javascript:get();" id="Button1" />
<input id="htmlButton" type="button" value="button" /><input id="btnHtmlSubmit"
type="submit" value="submit" />

推荐答案

Asp.net控件的ClientID 属性是控件的自动生成的标识.您应该使用ClientID 获取呈现控件时有关控件的详细信息.请参阅代码以获取类似的示例:
ASP.NET:如何解析客户端ID [ ^ ]
ASP.NET 4.0 ClientID概述 [ ^ ]


--Amit
The ClientID property of Asp.net controls is a automatically generated identification for a control. You should use ClientID to get the details about the controls when it is rendered. Refer the code for similar examples:
ASP.NET: How to Resolve Client ID[^]
ASP.NET 4.0 ClientID Overview[^]


--Amit


这篇关于呈现页面时如何区分HTML Button和Server Button.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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