问题描述
我有一个小型Web应用程序,该应用程序在本地计算机上运行良好,但是将站点部署到服务器后,所有其他按钮单击事件均正常运行,但一个按钮事件没有触发:
I have a small web application which is running well on my local machine but once I deploy my site to the server, all the other buttons click events are working except for one button event which is not firing:
public void checkpassword(object sender,EventArgs e)
{
string password = txtpassword.Text.ToString();
SqlConnection con = new SqlConnection(connect);
SqlCommand command = new SqlCommand("matchpassword",con);
con.Open();
command.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sqlDALogin1 = new SqlDataAdapter();
DataSet sqlDSLogin1 = new DataSet();
sqlDALogin1.SelectCommand = command;
sqlDALogin1.Fill(sqlDSLogin1, "Password");
string passwrd = Convert.ToString(sqlDSLogin1.Tables[0].Rows[0]["Password"]);
con.Close();
if (password == passwrd)
{
}
else
{
//Response.Redirect("ViewRecords.aspx");
lbldisplay.Text = "Wrong Password";
panelpassword.Update();
ModalPassword.Show();
}
}
<asp:Panel ID="Panel1" runat="server" CssClass="HellowWorldPopup2" Style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="BtnOK" runat="server" Text="OK" CssClass="lb-testright" OnClick="checkpassword"
/>
<asp:Button ID="BtnCancel" runat="server" Text="Cancel" CssClass="lb-testleft" OnClick="redirecttorecords" />
<asp:Button ID="Button1" runat="server" Text="Cancel" Style="display:none" />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="txtpassword" runat="server" CssClass="lb-textbox"
TextMode="Password" onfocus="clearContents(this);">Password </asp:TextBox>
<asp:ModalPopupExtender ID="Modal_Password" runat="server"
TargetControlID="Button1" PopupControlID="Panel1" DropShadow="true" >
</asp:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
这在我的机器上可以正常工作,但在部署时无法正常工作.
谢谢
This is working fine on my machine but what doesn''t work when deployed.
Thanks
推荐答案
<asp:Panel ID="Panel1" runat="server" CssClass="HellowWorldPopup2" Style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="BtnOK" runat="server" Text="OK" CssClass="lb-testright" OnClick="checkpassword"
/>
<asp:Button ID="BtnCancel" runat="server" Text="Cancel" CssClass="lb-testleft" OnClick="redirecttorecords" />
<asp:Button ID="Button1" runat="server" Text="Cancel" Style="display:none" />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="txtpassword" runat="server" CssClass="lb-textbox"
TextMode="Password" onfocus="clearContents(this);">Password </asp:TextBox>
<asp:ModalPopupExtender ID="Modal_Password" runat="server"
TargetControlID="Button1" PopupControlID="Panel1" DropShadow="true" >
</asp:ModalPopupExtender>
</ContentTemplate>
<triggers>
<asp:asyncpostbacktrigger controlid="BtnOK" eventname="Click" xmlns:asp="#unknown" />
</triggers>
</asp:UpdatePanel>
</asp:Panel>
http://msdn.microsoft.com/en-us/library/system. web.ui.asyncpostbacktrigger.aspx [ ^ ]
http://asp-net-example.blogspot.com/2009/11/ajax-asyncpostbacktrigger-how-to-use.html [ ^ ]
最好的问候
M.Mitwalli
http://msdn.microsoft.com/en-us/library/system.web.ui.asyncpostbacktrigger.aspx[^]
http://asp-net-example.blogspot.com/2009/11/ajax-asyncpostbacktrigger-how-to-use.html[^]
Best Regards
M.Mitwalli
这篇关于部署后按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!