Solved

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

Posted on 2004-09-14
8
4,456 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
Comment Utility
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
Comment Utility
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
Comment Utility
use response.redirect("Page.aspx?#bookmark")

zulu
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 18

Expert Comment

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

Author Comment

by:rgrimm
Comment Utility
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
Comment Utility
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
Comment Utility
Closed, 500 points refunded.
modname
Community Support Moderator
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

10 Experts available now in Live!

Get 1:1 Help Now