ASP.NET LinkButton OnClick Event Is Not Working On Home Page

依然范特西╮ 提交于 2019-12-20 03:07:29

问题


I have a user control that handles logging a user in to my site. This user control is placed in the upper right corner of all pages as a Quick Login Box. The problem I'm having is that on my production server, the LinkButton click events I have provided for logging in and reset are not firing the OnClick event after a postback. Its like it just forgets to do it.

Normally this wouldn't be such an issue to debug, except that it does not happen when running in debug on localhost (nor when running in release on localhost). It only seems to be occurring on my production server and only on my home page. If I try to login using the user control from any other page it works fine and the OnClick event runs as it normally should. I'm at my wits end here as I just don't know of anymore ways to debug this thing and every suggestion I've encountered on Google does not help. Below is the markup I'm using in my user control, any suggestions or help would be greatly appreciated. The LinkButton's "Login" and "Reset" do not work at all.

<asp:Panel ID="AnonPanel" runat="server" DefaultButton="Login">
<div id="welcome">
    <span class="welcome">Welcome </span><span class="guest1">Guest!</span>&nbsp; <span><a href="/login.html" class="guest">Login </a></span>|<span ><a href="/new-account-registration.html" class="guest"> Signup</a></span>
</div>
<div id="input_boxarea">
    <div id="user_id">
        <asp:TextBox ID="UserName" runat="server" CssClass="input_box1"></asp:TextBox>
    </div>
    <div id="password">
        <asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass="input_box1" size="16"></asp:TextBox>
    </div>
</div>
<div id="remember">
    <div id="reme">
        <div id="reme1">
            <asp:CheckBox ID="RememberMe" runat="server" />
        </div>
        <div id="reme2">Remember me</div>
    </div>
    <div id="loginbutton1"><span class="login"><asp:LinkButton ID="Login" 
            runat="server" CommandName="Login" onclick="Login_Click">Login</asp:LinkButton></span></div>
    <div id="resetbutton1"><span class="login"><asp:LinkButton ID="Reset" 
            runat="server" onclick="Reset_Click">Reset</asp:LinkButton></span></div>
 </div>

<asp:Panel ID="AdminPanel" runat="server" Visible="false">
<div id="welcome_loggedin">
    <span class="welcome">Welcome </span><span class="guest1"><asp:LoginName ID="LoginName1" runat="server" />!</span><br />
    <asp:HyperLink ID="MyAccountLink" CssClass="memberLink" runat="server" NavigateUrl="/my-account.html">My Account</asp:HyperLink><br />
    <asp:HyperLink ID="MyLeaguesLink" CssClass="memberLink" runat="server" NavigateUrl="/my-leagues.html">My Leagues</asp:HyperLink><br />
    <asp:HyperLink ID="AdminLink" CssClass="memberLink" runat="server" NavigateUrl="/admin/">Admin Area</asp:HyperLink><br />
    <asp:HyperLink ID="IssueTrackerLink" CssClass="memberLink" runat="server" Target="_blank">Issue Tracker</asp:HyperLink><br />
    <asp:HyperLink ID="Logout" CssClass="memberLink" runat="server" NavigateUrl="/logout.html">Logout</asp:HyperLink>
</div>

<asp:Panel ID="UserPanel" runat="server" Visible="false">
<div id="welcome_loggedin">
    <span class="welcome">Welcome </span><span class="guest1"><asp:LoginName ID="LoginName2" runat="server" />!</span><br />
    <asp:HyperLink ID="HyperLink1" CssClass="memberLink" runat="server" NavigateUrl="/my-account.html">My Account</asp:HyperLink><br />
    <asp:HyperLink ID="HyperLink2" CssClass="memberLink" runat="server" NavigateUrl="/my-leagues.html">My Leagues</asp:HyperLink><br />
    <asp:HyperLink ID="HyperLink3" CssClass="memberLink" runat="server" NavigateUrl="/logout.html">Logout</asp:HyperLink>
</div></asp:Panel>

回答1:


try changing "causes validation" property to false and see if that makes a difference.




回答2:


Could you temporarily perform some logging from those event handlers?

You could write to a .txt file on the web server. Or to the event log.

As the first line in the click event, write to the log. Then, perform the desired action (login, reset) in a try-catch block. Both the try and the catch write to the log again. If there's some weird exception happening, you can capture the details in your catch logging.

If you want to leave this temporary code in place, but don't want to perform logging unnecessarily, you could add a toggle in <appSettings> in your web.config file, so that you can turn the logging on and off.



来源:https://stackoverflow.com/questions/1953448/asp-net-linkbutton-onclick-event-is-not-working-on-home-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!