Hi Ron,
Thanks very much for your feedback.
Yes, you can view the lifecycle of asp.net web control like this:
"Control Execution Lifecycle"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconControlExecutionLifecycle.asp
Through this lifecycle, if you load control after
IPostBackEventHandler.RaisePostBackEvent method(Such as in PreRender
event), your control's event will not fire. So you should load it in
Page.Load event.
Also, sorry, you should refer to Page.Request.Form property, not
Page.Response.Form property, I think I have a typo error. Now, let me tell
you how to determine the postback through Page.Reqest.Form property.
In asp.net, the postback are forced through 2 ways(These are all client
side html and javascript behavior):
1. Explicitly invoke Form.Submit() method in javascript.
2. Render out a <input> html element with "submit" type. (That is a submit
button)
Normally, Button web control will render through the second way. While most
other controls such as TextBox(with AutoPostBack=true), LinkButton control
etc, are all using the first approach.
For the first approach, they all will render
"javascript:__doPostBack('unique id attribute','')" for their event
handler. While "__doPostBack" is a rendered javascript function, like this:
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
In the function, "__EVENTTARGET" and "__EVENTARGUMENT" are "theform"'s 2
hidden fileds. Like this:
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
So you will see that Asp.net will use this 2 hidden fileds to store the
postback causer's unique id, and related event parameter.
Then you may get the data at server side, through
Page.Request.Form["__EVENTTARGET"], the result value should be the "unique
id". Take "LinkButton" for example, it value should be "LinkButton1".
For the first approach, because it is a submit type <input> element, you
can get it at server side through: Page.Request.Form["button's unique id"],
the result value should be the "value" html attribute of that <input>
element(The default should be "Button")
For all my statement, you can determine through "View Source" of the
rendered result page.
At this point, I think I have explained clearly, the key point is the type
of your menu, are they linkbuttons? Or are they some other web controls?
If you use linkbuttons, they should have different unique names, you may do
like this to determine which linkbuttons are clicked:
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
this.Response.Write(this.Request.Form["__EVENTTARGET"]);
}
}
=====================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.