|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Page_Load Problem?My code: protected void Page_Load(object sender, EventArgs e) { string et = Request.Form["__EVENTTARGET"]; if ((IsPostBack) && (et.Equals(""))) { ExecuteCustomSearch(); } } There are times when I will click a button, and ExecuteCustomSearch() shouldn't run, but the EventHandler of that button should. However, if ExecuteCustomSearch() doesn't run (ie, if the if statement is false), the EventHandler for the button won't run. Why is this? How can I get around it? (PS: The buttons are created dynamicly, if that makes a difference) Why are you using Page_Load for a postback? If you caused a postback, you
should have an event handler for the event that caused the postback. That is where you should put the code. I assume that the postback in question could be handled without using EVENT_TARGET much easier with the event handler. Just a thought. -- Show quoteGregory A. Beamer ************************************************* Think Outside the Box! ************************************************* <matt.gra***@gmail.com> wrote in message news:1150745061.191194.176360@i40g2000cwc.googlegroups.com... > Hi all, > > My code: > protected void Page_Load(object sender, EventArgs e) > { > string et = Request.Form["__EVENTTARGET"]; > if ((IsPostBack) && (et.Equals(""))) > { > ExecuteCustomSearch(); > } > } > > There are times when I will click a button, and ExecuteCustomSearch() > shouldn't run, but the EventHandler of that button should. However, if > ExecuteCustomSearch() doesn't run (ie, if the if statement is false), > the EventHandler for the button won't run. > > Why is this? How can I get around it? > > (PS: The buttons are created dynamicly, if that makes a difference) > That really didn't answer my question at all...
Cowboy (Gregory A. Beamer) wrote: Show quote > Why are you using Page_Load for a postback? If you caused a postback, you > should have an event handler for the event that caused the postback. That is > where you should put the code. I assume that the postback in question could > be handled without using EVENT_TARGET much easier with the event handler. > Just a thought. > > -- > Gregory A. Beamer > > ************************************************* > Think Outside the Box! > ************************************************* > <matt.gra***@gmail.com> wrote in message > news:1150745061.191194.176360@i40g2000cwc.googlegroups.com... > > Hi all, > > > > My code: > > protected void Page_Load(object sender, EventArgs e) > > { > > string et = Request.Form["__EVENTTARGET"]; > > if ((IsPostBack) && (et.Equals(""))) > > { > > ExecuteCustomSearch(); > > } > > } > > > > There are times when I will click a button, and ExecuteCustomSearch() > > shouldn't run, but the EventHandler of that button should. However, if > > ExecuteCustomSearch() doesn't run (ie, if the if statement is false), > > the EventHandler for the button won't run. > > > > Why is this? How can I get around it? > > > > (PS: The buttons are created dynamicly, if that makes a difference) > > |
|||||||||||||||||||||||