Results 1 to 4 of 4

Thread: passing arguments

  1. #1

    Thread Starter
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950

    passing arguments

    How can I pass an argument to a page so that when it opens it knows what to display?

    Thanks,
    Don't anthropomorphize computers -- they hate it

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Query strings or using POST (using C#):

    Query String
    www.mydomain.com/mypage.aspx?item=abc
    Code:
    string myParam = Request.QueryString["item"];

    POST
    default.aspx (for e.g.):
    Code:
    <form id="formName" method="post" action="mypage.aspx">
      <input type="text" id="item" name="item" value="Blah">
    </form>
    mypage.aspx:
    Code:
    string myParam = Request.Form["item"];
    [Edit] I changed the field name in the <form>, but not in the code behind
    Last edited by axion_sa; Aug 26th, 2003 at 01:56 PM.

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Pass in a query string on the end of the url. Look at the address of this page, and you will see a query string after the .php and is started with the question mark.

    example:
    ?s=&postid=1510457

    Basically, this page is passing two parameters to the server: s and postid. The s variable isn't set to anything, but the postid is set to 1510457. The & symbol seperates values.

    You use the Request.QueryString in your code to get these values. You can store them in a System.Collections.Specialized.NameValueCollection object if you want to make working with them easier.

    Good luck.

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I was slow...lol.

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