Check this out for an explanation of how ASP.NET handles postback and what
the __EVENTTARGET is...

http://www.xefteri.com/articles/dec102002/default.aspx

The __EVENTTARGET is a hidden input control generated by ASP.NET that
indicates what control caused the postback, but it is not always present.
It gets created when certain controls are loaded on the page, such as the
DataGrid and the LinkButton.  In fact, it will only appears with a DataGrids
when the Grid holds buttons.

So your techinque will work in cases where your grid is the only control on
a page that causes ASP.NET to generate the __EVENTTARGET control and the
corresponding __doPostBack function.

HTH,

Dean Fiala
-----------------------------
Very Practical Software, Inc.
http://www.vpsw.com/links.aspx





-----Original Message-----
From: Rajendra Appalla [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 08, 2004 8:52 PM
To: [EMAIL PROTECTED]
Subject: [AspNetAnyQuestionIsOk] What about __EVENTTARGET ??? Dean,
Please look at this.
Importance: High


Hi,

I don't know what is __EVENTTARGET (please note there are two
underscores, not one before the word), but somehow I used it for a
unique situation I ran into and its helping me a lot. But I want to know
what is it and how reliable is my code for this situation.

I have a datagrid, I made enableviewstate = FALSE (datagrid on diet),
did custom paging, sorting etc.  I have two buttoncolumns too in the
datagrid.

But I was unable to fire the ItemCommand event or do sorting as I need
to bind the grid before page_load. But for my situation I should not
bind datagrid for postback of other controls on the page.

DEAN, if you remember, once we talked about this and you said you need
to bind the grid or for my particular situation you said to use the
following code:

String btnClicked = Request.Form.GetKey(3);
If(btnClicked.StartsWith("DataGrid1")
BindGrid();

I hope you remember this issue.

But when my page layout changed and had many other controls, the above
code failed.

So I was banging my head about this, and surprisingly I noticed that, if
the event occurred because of a control in the Datagrid, the
__EVENTTARGET is NOT NULL and if the event has occurred by a control
that is not inside the datagrid then __EVENTTARGET is NULL.

If(Request.Form["__EVENTTARGET"] != "")
BindGrid();

So I used this, and its working absolutely fine.  Is there really a
relation between DataGrid and __EVENTTARGET  and __EVENTTARGET exists
only DataGrid related events ?

So can I rely on this condition and model my datagrid?

Raj.




[Non-text portions of this message have been removed]




Yahoo! Groups Links









------------------------ Yahoo! Groups Sponsor ---------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to