Page_Load Problem?

  • Thread starter Thread starter matt.grande
  • Start date Start date
M

matt.grande

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)
 
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!
*************************************************
 
That really didn't answer my question at all...

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!
*************************************************
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)
 
Back
Top