dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: sending value from one page to another

  1. #1
    Join Date
    Oct 2006
    Posts
    128

    sending value from one page to another

    HI!
    I am desperately trying to solve a problem.
    I have a list of values which i display on a page.

    Code:
    file1
    
    file2
    
    
    file3
    When the user clicks on one of the file , a page should popup. I tried sending the value of file through query string but i can't make it to work. THe value is a COM interface object and it looks a bit weird on the urlstring as localhost/myproject?name=sys__combject.

    Is there any other way to send a com object ?

    Thanks

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: sending value from one page to another

    You have 2 options of doing this;

    1) Instead of passing the COM object as querystring, pass the id of the object (localhost/myproject?file_id=1). In the Page_Load of 'myproject' load the correct file/COM object.

    2) Store the clicked COM object in the Session, in the Page_Load of 'myproject' retrieve the COM object from the Session.


    But, I am not sure if this 2nd option works.

  3. #3
    Join Date
    Oct 2006
    Posts
    128

    Re: sending value from one page to another

    thanks for your quick reply. I'll try different value to pass as you suggested.

    Also, can you please be kind enough to tell me, what is the best way to carry same value to different pages. Say the first page send a string value( as query string) to the second page and the second page needs to send the same string and another string to the third page.

    Secondly, if i get this string value with Request.Querystring["name"].ToString() in one method of a page, what is the best way to call this value on other method. To explain, the string is retrived on page load function of a page, and i want to be able to access the string(or send it to the third page) on button click method. What is the ideal method i can use.

    Many thanks for your help.

  4. #4
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: sending value from one page to another

    First
    Quote Originally Posted by rachelason View Post
    Secondly, if i get this string value with Request.Querystring["name"].ToString()
    Request.QueryString already return an string, so you don't need to add .ToString() to the end of this method

    To answer your question
    Quote Originally Posted by rachelason View Post
    Also, can you please be kind enough to tell me, what is the best way to carry same value to different pages. Say the first page send a string value( as query string) to the second page and the second page needs to send the same string and another string to the third page.

    Secondly, if i get this string value with Request.Querystring["name"].ToString() in one method of a page, what is the best way to call this value on other method. To explain, the string is retrived on page load function of a page, and i want to be able to access the string(or send it to the third page) on button click method. What is the ideal method i can use.
    You still have same options, either via QueryString or Session. You can both access them through the whole page.

    For example
    Code:
    protected void button1_Click(object sender, EventArgs e){
      string valueToPassViaQueryString = Request.QueryString["myValue"];
      //do something
    
      //also possible is the next
      string valueToPassViaSession = Convert.ToString(Session["myValue"]);
    }

  5. #5
    Join Date
    Oct 2006
    Posts
    128

    Re: sending value from one page to another

    How can i use session in my example if i understood it right, session variables remain the same during a particular session.
    My requriement is if the user click first link it should carry a one value to the next page and if next link is clicked another value.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)