按钮点击导致IE浏览器asp.net中无法回发
我面临的行为非常奇怪。我有删除按钮,OnClick 我将其附加到该特定事件。我将整个数据存储在 Session 中,因此,在 if(!IsPostBack) 中,我在页面最初加载时清除会话。当我单击删除按钮而不是执行 IsPostBack = true 时,它会在 IE 中执行 IsPostBack = false 并重置会话数据。但是,使用其他浏览器我确实获得了预期的功能。 有人对这个问题有任何线索吗?
按钮标签 aspx 文件、
<tr id="rowPurpose">
<td>
<asp:Label ID="lblPurpose1" Font-Bold="true" runat="server">Purpose</asp:Label>
</td>
<td width="65">
<asp:Button ID="btnDeletePurpose1" Text="Delete" Visible="false" CommandArgument="lblPurpose1" OnClick="Delete_Purpose" runat="server" />
</td>
</tr>
C# 文件:
void page_load()
{
rowPurpose.Attributes["onclick"] = "javascript:Method('id')";
if (!Page.IsPostBack)
{
Session["Key"] = null;
}
}
提前致谢!
Its very strange behavior that I'm facing. I have delete button, OnClick I'm attaching it to that particular event. I'm storing my entire data in Session so, in if(!IsPostBack) i am clearing out the session when the page Initially loads. When i click on the delete button instead of doing IsPostBack = true it does IsPostBack = false in IE and resets the Session data. But, with other browser i do get the expected functionality.
Does any one have any clue about this issue ?
Button tag aspx file,
<tr id="rowPurpose">
<td>
<asp:Label ID="lblPurpose1" Font-Bold="true" runat="server">Purpose</asp:Label>
</td>
<td width="65">
<asp:Button ID="btnDeletePurpose1" Text="Delete" Visible="false" CommandArgument="lblPurpose1" OnClick="Delete_Purpose" runat="server" />
</td>
</tr>
C# file:
void page_load()
{
rowPurpose.Attributes["onclick"] = "javascript:Method('id')";
if (!Page.IsPostBack)
{
Session["Key"] = null;
}
}
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的是 HTML 提交按钮还是
。如果您不使用asp:Button
,那么它将不会执行回发,因为 asp 版本连接了PostBack
功能。还要确保按钮和表单上有runat="server"
属性。您可以在 ASPX 页面中发布您的按钮和表单标签吗?
Are you using an HTML submit button or an
<asp:Button>
. If you are not using theasp:Button
then it will not perform a post back since the asp version wires up thePostBack
functionality. Also make sure you have therunat="server"
attribute on the button and form.Can you post your button and form tag in your ASPX page?
我解决了这个问题。据我了解,发生这种情况是因为同时触发了两个事件,一个事件用于行,另一个事件用于按钮单击。所以我只是将单元格设置为可点击而不是整行,这工作正常。
谢谢
I got this resolved. From my understanding it was happening because of the two events that are firing at the same time one for the Row and other for the Button click. So i just made cell as clickable instead of whole row and this works fine.
Thanks