I am currently working on a project in ASP.NET (Framework 4.0) where I have implemented an Asp LinkButton in the Master Page that is linked to two different pages (Home.aspx and service.aspx).
The question at hand is: The LinkButton1 functions properly on Home.aspx but not on service.aspx.
Code for User.master:
<ul class="nav navbar-nav navbar-right">
<li>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" AutoPostBack="true">Signout
<i class="glyphicon glyphicon-off"></i>
</asp:LinkButton>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span>
<asp:Label ID="lblName" runat="server" Text=""></asp:Label>
</span>
<i class="icon-user fa"></i>
<i class=" icon-down-open-big fa"></i>
</a>
<ul class="dropdown-menu user-menu">
<li class="active">
<a href="frmUserHome.aspx">
<i class="icon-home"></i> My Account
</a>
</li>
<li >
<a href="frmUserHome.aspx">
<i class="icon-home"></i> Personal Home
</a>
</li>
<li>
<a href="#">
<i class="icon-hourglass"></i> Pending approval
</a>
</li>
</ul>
</li>
</ul>
User.master.cs code for handling LinkButton1 Click event:
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (Request.Cookies["ASP.NET_SessionId"] != null)
{
Response.Cookies["ASP.NET_SessionId"].Value = string.Empty;
Response.Cookies["ASP.NET_SessionId"].Expires = DateTime.Now.AddMonths(-20);
}
FormsAuthentication.SignOut();
Session.Abandon();
Response.Redirect("~/Default.aspx");
}
Upon inspecting elements using Chrome Browser, it was observed that on Home.aspx page the following code was present
<li>
<a id="ctl00_LinkButton1" autopostback="true" href="javascript:__doPostBack('ctl00$LinkButton1','')">Signout
<i class="glyphicon glyphicon-off"></i>
</a>
</li>
While on service.aspx, the following code was found during inspection:
<li>
<a id="ctl00_LinkButton1" autopostback="true" href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$LinkButton1", "", true, "", "", false, true))'>Signout
<i class="glyphicon glyphicon-off"></i>
</a>
</li>
Why is there a discrepancy between the code for Home.aspx and service.aspx when inspected through the Chrome browser?