T
tshad
I am trying to figure out how to handle a couple of problem using multiple
events tied to the same button.
Following is the button:
<asp:button ID="submitAnswer" CommandName="SubmitAnswer" runat="server"
style="color:#FF0000" Text="Submit Answer" OnClick="submitAnswer_click"
onInit="submitAnswer_onInit" OnLoad="submitAnswer_onLoad"
OnPreRender="submitAnswer_onPreRender" OnUnload="submitAnswer_onUnload"
oncommand="submitAnswer_onCommand"/>
Following is the trace with a trace.warn in each event.
aspx.page Begin Init
aspx.page End Init
aspx.page Begin LoadViewState
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
aspx.page End LoadViewState
aspx.page Begin ProcessPostData
aspx.page End ProcessPostData
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
aspx.page Begin ProcessPostData Second Try
aspx.page End ProcessPostData Second Try
aspx.page Begin Raise ChangedEvents
aspx.page End Raise ChangedEvents
aspx.page Begin Raise PostBackEvent
inside SubmitAnswer_click
Inside submitAnswer_onCommand
aspx.page End Raise PostBackEvent
aspx.page Begin PreRender 0.012925
Inside submitAnswer_onPreRender
aspx.page End PreRender
aspx.page Begin SaveViewState
aspx.page End SaveViewState
aspx.page Begin Render
aspx.page End Render
Why does the OnInit and OnLoad fire fire 8 times each?
Why is there no onUnload firing?
I tried in my onInit, onLoad and onClick event to turn off my onPreRender
event using :
Sender.Attributes.Add("onPreRender", "")
But it still fires.
I also tried to add an event from the onInit event of the button like so:
Sender.Attributes.Add("onPreRender", "submitAnswer_PreRender")
But it didn't fire.
I assume this is because all the events are collected when the button is
pushed, so changing it from runtime wouldn't help.
Tom
events tied to the same button.
Following is the button:
<asp:button ID="submitAnswer" CommandName="SubmitAnswer" runat="server"
style="color:#FF0000" Text="Submit Answer" OnClick="submitAnswer_click"
onInit="submitAnswer_onInit" OnLoad="submitAnswer_onLoad"
OnPreRender="submitAnswer_onPreRender" OnUnload="submitAnswer_onUnload"
oncommand="submitAnswer_onCommand"/>
Following is the trace with a trace.warn in each event.
aspx.page Begin Init
aspx.page End Init
aspx.page Begin LoadViewState
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
Inside submitAnswer_onInit sender = System.Web.UI.WebControls.Button
aspx.page End LoadViewState
aspx.page Begin ProcessPostData
aspx.page End ProcessPostData
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
Inside submitAnswer_onLoad
aspx.page Begin ProcessPostData Second Try
aspx.page End ProcessPostData Second Try
aspx.page Begin Raise ChangedEvents
aspx.page End Raise ChangedEvents
aspx.page Begin Raise PostBackEvent
inside SubmitAnswer_click
Inside submitAnswer_onCommand
aspx.page End Raise PostBackEvent
aspx.page Begin PreRender 0.012925
Inside submitAnswer_onPreRender
aspx.page End PreRender
aspx.page Begin SaveViewState
aspx.page End SaveViewState
aspx.page Begin Render
aspx.page End Render
Why does the OnInit and OnLoad fire fire 8 times each?
Why is there no onUnload firing?
I tried in my onInit, onLoad and onClick event to turn off my onPreRender
event using :
Sender.Attributes.Add("onPreRender", "")
But it still fires.
I also tried to add an event from the onInit event of the button like so:
Sender.Attributes.Add("onPreRender", "submitAnswer_PreRender")
But it didn't fire.
I assume this is because all the events are collected when the button is
pushed, so changing it from runtime wouldn't help.
Tom