user1637402
user1637402

Reputation: 87

page life cycle make me confused?

i clicked abutton then depug enter page load before button click event i want to check in page load if this button clicked

i used hiddenfield and javascript function like

   <script type="text/javascript">
 function CheckClicked() {
     form1.HiddenField2.Value = span1.innerHTML;
      alert(form1.HiddenField2.Value);

   }
  </script>

and this is my button

<asp:Button id="cmd_Edit" CssClass="button rnd-sml" runat="server" text="edit" OnClick="cmd_Edit_Click" Visible="False" onclientclick="CheckClicked()" />

OK when click alert popup and it's value is true

when i checked in page_load event like

           if (HiddenField2.Value!="True")
            {
                FillData();
            }

HiddenField2.Value =null i don't know why where it's value(True) there was true in alert when came to page load became null

i need method to know if my button clicked before entered to button click event is there? plz i need help

Upvotes: 0

Views: 145

Answers (2)

ertan
ertan

Reputation: 705

Page Load event is raised before postback values are processed.

Try to call "FillData" on OnPreRender event to prevent from this.

Upvotes: 1

Steven Hunt
Steven Hunt

Reputation: 2321

First, have you checked the actual name of your hidden field on the page? Asp .net likes to change them from what you think they are, so the name will probably be different for javascript. Also, try document.getElementById('whatever_the_id_is').value = document.getElementById('your_span').innerHTML; which uses IDs instead of names.

Upvotes: 0

Related Questions