weird button problem

Results 1 to 2 of 2

Thread: weird button problem

  1. #1
    Join Date
    Dec 1969

    Default weird button problem

    I've got a button that is added dynamically to my page instead of in the html view. In my InitializeComponent, I create the button and add it's event handler to the page. Then, later I create a table object and add this button to one of the cells. What is strange is in my page_load method, if I do not do a check for !IsPostBack, then the event handler will fire just fine. However, if I do any type of check to see if !IsPostBack, then it never reaches the event handler. I'm mystified as to why. Anyone have any ideas? Thanks.

  2. #2
    Join Date
    Dec 1969

    Default Where do you wire up...

    ...the event handler???<BR><BR>If you do it in the code that isn&#039;t reached on a post back, then of course it&#039;s not there.<BR><BR>Remember, *EACH INSTANCE* of an .aspx page is a SEPARATE ENTITY.<BR><BR>So if you wire up the button on the first page but then don&#039;t do so on the post back, the HTML that the web server sends back to the browser won&#039;t include the JS needed to handle that event.<BR><BR>To see the difference, try this:<BR>-- bring up the page in a new browser (so it&#039;s not a postback)<BR>-- click on the VIEW menu, the SOURCE menu item, see the HTML in notepad<BR>-- do something that posts that page (so it *IS* a postback)<BR>-- click on the VIEW menu, the SOURCE menu item, see the HTML in notepad<BR><BR>Compare the two different sets of HTML (with JS embedded, of course). Look at your button. See the differences between them?<BR><BR>************<BR><BR>This is mostly guess on my part, since your details were sparse.<BR><BR>But when in doubt, go look at the HTML being generated to see what&#039;s going on.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts