Solved

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

Posted on 2004-09-14
8
4,467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
How our DevOps Teams Maximize Uptime

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

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I bind a WPF ComboBox to an ItemSource using XAML? 2 32
Name Space error VS2015 1 37
Amazon S3 Images with .Net 3 34
Header Font Size in Grid View 6 27
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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