Solved

Server.Transfer and "Error executing child request for..." error.

Posted on 2004-09-14
8
4,458 Views
Last Modified: 2008-02-07
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?
0
Comment
Question by:rgrimm
8 Comments
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12060701
I am using Javascript to do that. Here is an example..

    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.scrollTo(0,812);</script>"
        If (Not Page.IsStartupScriptRegistered("clientScript")) Then
            Page.RegisterStartupScript("clientScript", stscript)
        End If
    End Sub

-Baan
0
 

Author Comment

by:rgrimm
ID: 12060881
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.
0
 
LVL 6

Expert Comment

by:zulu_11
ID: 12063399
use response.redirect("Page.aspx?#bookmark")

zulu
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12063578
That will cause a postback...  I was trying to avoid a post back.
0
 

Author Comment

by:rgrimm
ID: 12065769
I tried using both of the following:

Server.Transfer("Page.aspx?#Bookmark")
Response.Redirect("Page.aspx?#Bookmark")

Both cause a fresh, blank page to reload, which I don't want. I need a postback that maintains the page state.
0
 

Author Comment

by:rgrimm
ID: 12109154
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("MoveToAnchor", "<script language=JavaScript>document.location.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.Count > 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 
 
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12151580
Closed, 500 points refunded.
modname
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now