Below sequence fires.
* At first time 'onload="Hide()' hides the label.
* When the button is clicked below event happens:
- button_clientside_click : Avoid 'OnClientClick="UnHide();'. Instead modify it as 'OnClientClick="Hide();'
- Page_Load: This will make it visible due to declarative values.
- Button_ServerSide_Click : Sleeps thread for 2 secs.
- Page_PreRender
- body_onload_clientside : This will not happen. This is the root cause.
- Page_Render : Lable gets Visible.
- Page_Unload
Hence when the button is clicked you will find the Label as 'Visible'.
// ------------------------------------------------
function Hide()
{
document.getElementById('Label1').style.display='none';
}
<ContentTemplate>
<asp:Button ID="Inner" runat="server" Text="Inner" OnClick="Button1_Click" OnClientClick="Hide();" /> <br /><br />
<asp:Label ID="Label1" runat="server" Text="Error Label" ForeColor="Red"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<script language="javascript">
window.onload=Hide();
</script>
// ------------------------------------------------
Hope it is Clear.
No comments:
Post a Comment