M
mschoup
I have a simple aspx page(WebForm1.aspx) with a HyperLink, LinkButton,
and two CheckBoxes. When I select a CheckBox and then click the
LinkButton, the CheckBox retains state. When I select the CheckBox and
click the HyperLink (NavigateURL set to WebForm1.aspx), the CheckBox
lost it's state.
I would assume that this is by design (now that I read ASP.NET in a
nutshell) where it describes a HyperLink control action as 'navigates
from one page to another when clicked' whereas the LinkButton action is
described as 'posts a form to the server when clicked.' Just wanted to
confirm if anyone has seen this before and if this is indeed what I'm
running into. Thanks.
WebForm1.aspx
<%@ Page language="c#"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="WebForm1" method="post" runat="server">
<P>
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="WebForm1.aspx">HyperLink</asp:HyperLink>
<asp:LinkButton id="LinkButton1"
runat="server">LinkButton</asp:LinkButton></P>
<P>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
<asp:CheckBox id="CheckBox2" runat="server"></asp:CheckBox></P>
</form>
</body>
</HTML>
and two CheckBoxes. When I select a CheckBox and then click the
LinkButton, the CheckBox retains state. When I select the CheckBox and
click the HyperLink (NavigateURL set to WebForm1.aspx), the CheckBox
lost it's state.
I would assume that this is by design (now that I read ASP.NET in a
nutshell) where it describes a HyperLink control action as 'navigates
from one page to another when clicked' whereas the LinkButton action is
described as 'posts a form to the server when clicked.' Just wanted to
confirm if anyone has seen this before and if this is indeed what I'm
running into. Thanks.
WebForm1.aspx
<%@ Page language="c#"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="WebForm1" method="post" runat="server">
<P>
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="WebForm1.aspx">HyperLink</asp:HyperLink>
<asp:LinkButton id="LinkButton1"
runat="server">LinkButton</asp:LinkButton></P>
<P>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
<asp:CheckBox id="CheckBox2" runat="server"></asp:CheckBox></P>
</form>
</body>
</HTML>