|
-
Aug 26th, 2003, 11:50 AM
#1
Thread Starter
Frenzied Member
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
-
Aug 26th, 2003, 12:23 PM
#2
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.
-
Aug 26th, 2003, 12:23 PM
#3
PowerPoster
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.
-
Aug 26th, 2003, 12:32 PM
#4
PowerPoster
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|