rgrimm
asked on
Server.Transfer and "Error executing child request for..." error.
In my web page I have an HTML anchor tag that acts as a bookmark:
<A name="bookmark"></A>
When a command button on the page is clicked, I do a postback. If certain conditions exist, then I want to jump to the above bookmark. I use a line of code that looks like this:
Server.Transfer("#bookmark ")
This generates the following error on the Server.Transfer line:
"Error executing child request for #bookmark."
How do I make my code jump to this bookmark?
<A name="bookmark"></A>
When a command button on the page is clicked, I do a postback. If certain conditions exist, then I want to jump to the above bookmark. I use a line of code that looks like this:
Server.Transfer("#bookmark
This generates the following error on the Server.Transfer line:
"Error executing child request for #bookmark."
How do I make my code jump to this bookmark?
ASKER
The JavaScript scrollTo method takes two arguments: xPosition and yPosition. It moves you to a specified x,y coordinate (origin is the top-left corner of the window) on the page. I need to go to a specific anchor tag.
use response.redirect("Page.as px?#bookma rk")
zulu
zulu
That will cause a postback... I was trying to avoid a post back.
ASKER
I tried using both of the following:
Server.Transfer("Page.aspx ?#Bookmark ")
Response.Redirect("Page.as px?#Bookma rk")
Both cause a fresh, blank page to reload, which I don't want. I need a postback that maintains the page state.
Server.Transfer("Page.aspx
Response.Redirect("Page.as
Both cause a fresh, blank page to reload, which I don't want. I need a postback that maintains the page state.
ASKER
Here is the solution. It works great. Many thanks to Keem. See the link at the bottom for the entire discussion thread.
In VB.NET Create a method something like this...
Private Sub MoveToAnchor(ByVal anchorName As String)
'Returns page to the given anchor
Page.RegisterStartupScript ("MoveToAn chor", "<script language=JavaScript>docume nt.locatio n.hash = '" & anchorName & "'</script>")
End Sub
Then if you have an anchor
<a name="Bookmark"></a>
In the VB.NET code just change your code to
If repSearchResults.Items.Cou nt > 0 Then 'If repeater control has records, show panel, hide buttons
pnlDuplicate.Visible = True
cmdUpdate.Visible = False
cmdCancel.Visible = False
MoveToAnchor("Bookmark")
End If
( i'm guessing here that you are posting back to the same page, other wise you'd do do a Server.Transfer to the required page and then the call the MoveToAnchor )
************************** ********** ********** **********
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=263244&Page=1#264260
In VB.NET Create a method something like this...
Private Sub MoveToAnchor(ByVal anchorName As String)
'Returns page to the given anchor
Page.RegisterStartupScript
End Sub
Then if you have an anchor
<a name="Bookmark"></a>
In the VB.NET code just change your code to
If repSearchResults.Items.Cou
pnlDuplicate.Visible = True
cmdUpdate.Visible = False
cmdCancel.Visible = False
MoveToAnchor("Bookmark")
End If
( i'm guessing here that you are posting back to the same page, other wise you'd do do a Server.Transfer to the required page and then the call the MoveToAnchor )
**************************
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=263244&Page=1#264260
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim stscript As String = "<script language=JavaScript>self.s
If (Not Page.IsStartupScriptRegist
Page.RegisterStartupScript
End If
End Sub
-Baan