1

I am working in C#(asp.net). I have two pages 'abc.aspx' and 'xyz.aspx'. I want to send data from 'abc.aspx' to 'xyz.aspx'. I am using this code.

In 'abc.aspx'

<form action='xyz.aspx?site=google&code=123' method='get'>
<input type='text' name='name1' />
<input type='submit' value='submit' />
</form>

Now, I want to access all three values (site,code and name1). But, in 'xyz.aspx', I got only one value i.e name1. How to get all three values.

Sagar
  • 7,115
  • 6
  • 21
  • 35
  • Duplicate of http://stackoverflow.com/q/1116019/639945 – Jeremy Rosenberg Aug 04 '12 at 19:19
  • @JeremyRosenberg Yes this question is duplicate but I have the same question like him. "Yes, ofcourse I would do this if possible. But lets say I have parameters in query string and in hidden inputs, what can I do?" I didn't find answer of this question. – Sagar Aug 04 '12 at 19:40

2 Answers2

2

You need to put the values into hidden <input /> elements and hard-code the values if you want to have them end up in the query string. You're correct in setting the method='get':

<form action='xyz.aspx' method='get'>
  <input type='hidden' name='site' value='google' />
  <input type='hidden' name='code' value='123' />
  <input type='text' name='name1' />
  <input type='submit' value='submit' />
</form>
Yuck
  • 49,664
  • 13
  • 105
  • 135
0

I think this one is the best.

In abc.aspx

<form action="xyz.aspx?site=google" method="post">
<input type="text" name="name1" />
<input type="submit" value="Submit" />
</form>

In xyz.aspx, access the data like this..

string site = Request.QueryString["site"];
string name = Request.Form["name1"];
//Remaining code...
Sagar
  • 7,115
  • 6
  • 21
  • 35
  • No it's not. Use Yuck's answer. Just because you can doesn't mean you should. It's like holding your right ear with your left hand through on top of your head. – Umur Kontacı Aug 05 '12 at 10:27