Ask a Question related to ASP.NET General, Design and Development.
-
Jeff Voigt #1
What Control Caused the PostBack?
Is there any way to dynamically get the name of the control that caused the
postback? Since SmartNav is not working for me I'm trying to implement a way
to scroll to the control that caused the post back so the user does not have
to scroll all the time.
I got the script working great and everything else, but I want to be able to
tell the name of the control that posted back. That way we don't have to
hard code much at all.
This is what I have implemented so far:
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
' automatically scroll to the object that posted back (if applicable)
If Page.IsPostBack > 0 Then
RegisterStartupScript("scroll", "<script language=javascript>" +
_scrollToObjectPath + _scrollToObjectName + ".scrollIntoView();</script>")
End If
End Sub
Thanks in advance,
- Jeff
Jeff Voigt Guest
-
Determining What Control Caused The PostBack
I have a DataList that I was having trouble getting the events for. After a bit of help, I realized that I needed to put the databinding inside an... -
help with postback-less calendar control.
hi, I need to create a Calendar control that does not do postback when a date is selected...any ideas on how to do this thanks in advance... -
Did my control caused the postback
You want to know it on Page or in the control itself? If your control implements IPostBackEventHandler, you could override RaisePostBackEvent on... -
How to determine Control that caused Postback?
My event target is blank. Why would it be blank? I put a value in for the CommandArgument and CommandName. I am using the following syntax...... -
How to see what caused PostBack
I have few buttons on a page. In Page_Load I would like to determine which one caused post back. How to do? -
John Saunders #2
Re: What Control Caused the PostBack?
"Jeff Voigt" <jeffrey.voigt@djj.state.fl.us> wrote in message
news:ezpBSPdXDHA.2352@TK2MSFTNGP12.phx.gbl...the> Is there any way to dynamically get the name of the control that causedway> postback? Since SmartNav is not working for me I'm trying to implement ahave> to scroll to the control that caused the post back so the user does notJeff, you could look at the value of the __EVENTTARGET hidden field via> to scroll all the time.
Request.Form["__EVENTTARGET"].
You should note that although this will work in many cases, it won't work
for all. ASP.NET searches the control tree looking for a control with its
ClientID equal to __EVENTTARGET and implementing IPostBackEventHandler. If
found, it will pass __EVENTTARGET and __EVENTARGUMENT to this controls
RaisePostBackEvent method.
Usually, __EVENTTARGET is the ClientID of a single control in a single place
on the page. But a composite control may have many child controls which can
post back, and __EVENTTARGET may only name a single hidden field located in
front of all of those child controls. The composite control might then use
__EVENTARGUMENT to distinguish which child control caused the postback, but
you would be unable to do so.
Another issue would be the case where a button causes the postback, but that
it is "clicked" via its accessKey attribute. This button might not be
anywhere near where the user was working when he pressed the access key.
Is there anything in the DOM which would give you a better idea of "what
part of the window is visible right now"? If so, you might capture onsubmit
and cause that information to be sent to the host, which could send it back
to the page in the response. Code in the onload handler on the page might
then be able to restore that information.
--
John Saunders
Internet Engineer
[email]john.saunders@surfcontrol.com[/email]
John Saunders Guest
-
eruess #3
Re: What Control Caused the PostBack?
You may be able to get it from Request.Form("__EVENTTARGET"), but AFAIK
that's only generated by asp.net if one of your controls, such as a
combobox, has it's AutoPostBack property set to True. I'm not 100% sure on
that.
"Jeff Voigt" <jeffrey.voigt@djj.state.fl.us> wrote in message
news:ezpBSPdXDHA.2352@TK2MSFTNGP12.phx.gbl...the> Is there any way to dynamically get the name of the control that causedway> postback? Since SmartNav is not working for me I'm trying to implement ahave> to scroll to the control that caused the post back so the user does not> to scroll all the time.
eruess Guest



Reply With Quote

