为什么控件没有传递给从aspx到aspx.cs的button_Click()事件 [英] why control is not pass to button_Click() event from aspx to aspx.cs

查看:247
本文介绍了为什么控件没有传递给从aspx到aspx.cs的button_Click()事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也这样做

I am also do this

<asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>



< asp:button ID =btn2runat =serverText =Delete Selected

onclick =btn2_Click/>


<asp:button ID="btn2" runat="server" Text="Delete Selected"
onclick="btn2_Click" />

</ContentTemplate>
 <Triggers>
     <asp:PostBackTrigger ControlID="btn2" />
     </Triggers>
   </asp:UpdatePanel>

推荐答案

您好,



请添加属性AutoPostBack =true,然后查看。



Autopostback是一种机制,通过该机制,页面将根据Web控件中的某些事件自动发回服务器。在某些Web控件中,该属性称为自动回发。



如果设置为true,它将在事件发生时将请求发送到服务器控件。



每当我们在任何控件中将autopostback属性设置为true时,.net框架会自动将少量代码插入到生成的HTML中以实现此功能。



1.)一个名为__doPostBack的Java脚本方法(eventtarget,eventargument)

2.)两个名为__EVENTTARGET的隐藏变量__EVENTARGUMENT

3.)OnChange JavaScript事件到控件



希望这有帮助:)



问候,

Praneet
Hi,

Please add a property AutoPostBack="true" and then check.

Autopostback is the mechanism, by which the page will be posted back to the server automatically based on some events in the web controls. In some of the web controls, the property called auto post back.

If it is set to true,it will send the request to the server when an event happens in the control.

Whenever we set autopostback attribute to true in any of the controls, the .net framework will automatically insert few code in to the HTML generated to implement this functionality.

1.) A Java script method with name __doPostBack (eventtarget, eventargument)
2.) Two Hidden variables with name __EVENTTARGET and __EVENTARGUMENT
3.) OnChange JavaScript event to the control

Hope this helps :)

Regards,
Praneet


这篇关于为什么控件没有传递给从aspx到aspx.cs的button_Click()事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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