server.transfer

Last post 10-29-2009 10:54 PM by chetan.sarode. 5 replies.

Sort Posts:

  • server.transfer

    09-06-2006, 11:29 AM
    • Member
      15 point Member
    • danchristie
    • Member since 09-01-2006, 6:02 PM
    • Posts 3

    I posted this earlier but have narrowed down my problem. I am using server.transfer in an update panel. To be consistant with the rest of the app I'd like to continue using this if possible. I get "unknown error" and from what I am reading there are problems with server.transfer and updatepanels. I have tried this in a sample application with only one update panel containing a link button which calls server.transfer when clicked. Nothing else going on. Without the update panel the user is transfered, with it I get unknown error.

     Has anyone gotten around this while continuing to use server.transfer?

     

    Thanks.

  • Re: server.transfer

    09-19-2006, 2:08 PM
    • Member
      16 point Member
    • Soledad
    • Member since 09-19-2006, 5:59 PM
    • Posts 8

    I have the same problem.

    I'm using an ImageButton in a GridView, which calls to Server.Transfer(),  and throws an Unknown error.

    It works with Response.Redirect() but I can't pass any parameter.

    I really need to pass some data from one page to another, but in a secure way. (if I pass  an ID with Response.Redirect I should encrypt it, because it goes back to the client). Is there another way to achive this?

    Thanks. 

     

     

     

     

  • Re: server.transfer

    09-28-2006, 5:27 PM
    • Member
      5 point Member
    • ntColonel
    • Member since 09-28-2006, 8:57 PM
    • Posts 1

    Server.Transfer() probably won't ever work unless somebody makes the ATLAS scripts somehow smarter.

    Here's what I think happens with the UpdatePanel:

    1) You click on the GridView row.

    2) The UpdatePanel performs a POST in the background while it displays the old data.

    3) When the page finishes rendering in the background, it basically does a cut-n-paste of the area under its control from the invisible background page to the visible foreground page.

    4) When you Server.Transfer(), ATLAS has a fit because when the URL of the invisible background page is the same, but it can't find the control it wants within there to paste into the visible window.

     

    What you'll want to do is a Cross Page PostBack with a button control.

    Here's how you do that:

    1) Create a template field.  You can convert one of your bound fields to a template field and it won't make a new, empty column.

    2) In your template field, place an <asp:button /> control, setting the CommandName, CommandArgument and PostBackURL properties.

    Mine looks like this:

    <asp:Button runat="server"  id="viewRow" style='display:none' CommandName='Select' CommandArgument='<%# Eval('itemId') %>' PostBackUrl='~/Stuff/ViewItem.aspx' />

    3) Override the page's Render() method:

    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

        ...other render code you may write...
     

        For Each row As GridViewRow In MyGridView.Rows

            If row.RowType = DataControlRowType.DataRow Then

               row.Attributes.Add("onClick", "document." & Page.Form.ClientID & "." & row.FindControl("btnViewRow").ClientID & ".click();") 

           End If
        Next

       ...other render code you may write...

       MyBase.Render(writer)

    End Sub

     

    4) Define a property to expose the selected item to the desination page.

    Public ReadOnly Property ItemId() As Integer

       Get

          Return MyGridView.SelectedValue

        End Get

    End Property
     

    5) Now all you have to do after that is write your receiving page to handle a Cross Page PostBack, you can search for the instructions on how to do that in Google.

    The effect is the same as PostBack + Transfer, you just POST somewhere else instead of transfering. The ATLAS stuff seems to be fine with it.

  • Re: server.transfer

    10-13-2006, 4:09 PM
    • Member
      16 point Member
    • Soledad
    • Member since 09-19-2006, 5:59 PM
    • Posts 8

    Thank you. It works!!!

     

     

     

  • Re: server.transfer

    10-29-2009, 6:40 AM
    • Member
      4 point Member
    • manang
    • Member since 10-29-2009, 10:31 AM
    • Posts 2

    http://msmvps.com/blogs/luisabreu/archive/2007/10/10/no-you-cannot-call-server-transfer-on-an-asp-net-ajax-enabled-page.aspx

     Please refer to this for the above query.

     

  • Re: server.transfer

    10-29-2009, 10:54 PM
Page 1 of 1 (6 items)