Fabrizio,
In page load you can check to see who fired the event depending on the type
of webcontrol, one of these always works :
If Request.Params.Item("btnSubmit") <> Nothing Then
Else
End If
If Request.Params("btnSubmit") <> Nothing Then
Else
End If
If Request.Form("btnSubmit") <> Nothing Then
Else
End If
dim s as string
s = Request.Params.Get("__EVENTTARGET")
If s = "btnSubmit" then
Else
End if
As for you dataGrid events you will have to code inside the appropriate
methods exposed by the dataGrid. This control is a container control and all
events fired within this container are bubbled up and handled within the
handlers exposed by this control. A good place to check for click events is
the OnItemCommad method. This allows you to provide a custom handler for
the event.
For your last question, as you would have already noted when using controls
that postback in asp.net, some javascript code is injected into your page :
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform = document.myForm;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
this is the __doPostBack function which is called by any of our controls
that postback. What it does is it takes an eventTarget(the control ID that
is postback) and an eventArgument(this is extra info you might want to pass
along with the event) and sets these values into the hiddenfields before
causing the form to submit. This is how your webform knows who postback etc.
You can call this funtion from any clientside code you might have and pass
it an id.
Please note however that this script is injected into the page only when
there is a control on your webform that postsback, so for you to be able to
call this function from your clientside code you need to have atleast one
control on your webform that postsback. otherwise you would be calling
_doPostBack but the function is never there coz it was never injected into
your page.
Fabrizio said:
Eh, sorry for being not so clear.
Thinking about it i can set the question in a much simple way (the code i
could show would not clear the nature of the problem, it's all in my mind

).
Being in the Page_Load of a WebForm how can i know if an event is going to
fire ? a button_click, a grid_itemcommand, and so on.
Can i see also events fired in a user control in the web form ?
Can i see the event also in the page load of the user control ?
And a last question connected, how do i call a __PostBack from javascript in the correct manner ?
P.S. Speaking about my problem i found really good use of the
Page_PreRender event, but i would still like to know if i can get this
information.