Results 1 to 10 of 10

Thread: Server.Transfer help plz

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Server.Transfer help plz

    I have created a search page with 4 fields. When the user clicks on the search button i pass the data from these fields to another aspx page using server.transfer method. Using this data i create a dynamic sql and retrieve data from the server and display it to the user. I am alsu using page. But what happens is when the page index chagned is fired, i loose the data in the variables. Can anyone tell me an effcient way to store the data of these variables until the user has not moved out. I know it can be done using session variables but is there any other way.

    than

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: Server.Transfer help plz

    I'm not sure what you mean by 'page'.

    Do you mean, Paging in a datagrid? Your post is confusing...

    You can store the values on the viewstate (preferably), or in hidden fields (it's still considered an Okey practice for non-vital information).

    I would use viewstate.

    If this is not what you were looking for, refrase your question.

    HTH
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Re: Server.Transfer help plz

    sorry i mean paging...i m using paging while displaying records...can you please tell me an example on how to store it in the view state..any example..thanx

  4. #4
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: Server.Transfer help plz

    If you only do PostBack on that screen, you always have the querystrings at the top of the browser to retrieve the values again each time, you don't even need extra code.

    It's not that secure, since the user can manually alter the querystring. But if the information is not vital, and it's just a search engine, then there's nothing you can do on the querystring that you can't do on your search page.

    Now, onto the 'storing stuff into viewstate' part:

    Set:
    VB Code:
    1. ViewState(key) = value
    Get:
    VB Code:
    1. Value = ViewState(key)

    HTH
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Re: Server.Transfer help plz

    Thanks but what if the view state is disabled in the web page

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Re: Server.Transfer help plz

    By default, the Server.Transfer method does not pass the form data or the query string of the original page request to the transferred page. But you can preserve the form data and query string of the original page by setting the optional second argument of the method to True. When you use this technique, though, you need to aware of one thing: the destination page uses the same response stream that was created by the original page, and therefore the hidden _VIEWSTATE field of the original page ends up on the second page. This causes the ASP.NET machine authentication check (MAC) to assume that the ViewState of the new page has been tampered with. Therefore, when you choose to preserve the form and query string collection of the original page, you must set the EnableViewStateMac attribute of the Page directive to False for the destination page.

    This is confusing me..the article i read..its just an extract of it

  7. #7
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: Server.Transfer help plz

    I wouldn't use the preserve form overload of server.transfer. It's complicated. You should keep it simple or it will turn into a nightmare.

    The incredible simple way to solve this is to pass the values trough the QueryString, as you pointed at first, and then just keep reading the values from the queryString at Page.Load everytime the page is called, even when it's a PostBack.

    You solve all this problem in two lines.

    HoraShadow

    PS: I'll be online for 15 more minutes.
    I do like the reward system. If you find that my post was useful, rate it.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    Re: Server.Transfer help plz

    I think i would use server.transfer and when it is transferred to the detination web page it would be good to save them in viewstate name/value pairs. If the page index changed is called it would just get the value from the viewstate. i think this sorts out good..although i m new to asp.net..coming from asp..but i dont like to use querystring. thanx

  9. #9
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: Server.Transfer help plz

    Ok, post when you finish it and what way you finally implemented.

    Take care
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: Server.Transfer help plz

    Viewstate disabled for a page isn't viewstate disabled in the application. It's just for the page

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width