Simple Request, sending variables ..

liunx

Guest
I have googled until i could no more. Tons of pages msnd pages, and many more have i visited.

Could somebody put some code here for :

A simple form with 1 Textbox & a submit button (using webcontrols)

And how to send & get the information in another page?



<form method="post" action="test2.aspx" runat="server" ID="Form1">


<!--Name textbox -->
<B>Name:</B>
<asp:Textbox id="txtName" runat="server"/>

<input type="text" id="txtAge" runat="server" NAME="txtAge"/>
<asp:button type="submit" name="btnSubmit"
onclick="btnSubmit_OnClick"
text="Submit Form!" runat="server" ID="Button1"/>

</form>


why use asp:Textbox in one and input type... runat="server"
in the other?
What is the difference?

In my test2.aspx how can i get the values from both textboxes?

what to put in the btnSubmit_OnClick() fromt the button? how to pass the information and how to retrieve in it test2.aspx?Originally posted by darktown

<form runat="server" ID="Form1">
<!--Name textbox -->
<B>Name:</B>
<input type="text" id="txtName" runat="server"/>
<input type="text" id="txtAge" runat="server"/>
<input type="submit" ID="Button1"/>
</form>

there isn't a big difference between using the ASP HTML controls and actual HTML tags... just that with the ASP versions there are certain attributes you can specify that were designed to make life easier. in this case it won't really change anything. also, the submit button does not need any additional code to submit, it doesnt even need a runat='server'.

however.. in ASP.NET there is no multipage submissions, you cannot submit to another page.. it's the way it was designed with the viewstate and all in mind, assuming it submits to itself. you will have to use another method of passing variables, such as sessions, cookies, or cache... the best option (IMO) is to create all your pages within one ASPX file, as separate ASP:panel (div) controls.. then just hide/show appropriately.come on this cannot be!!
Anybody else that can say how to pass variables that i submit from the form to another page?

If it's really like this. i am just going to use html input types and use request.form("") on the other page.

really weird way of working i think .. :shehe... it was very easy to do so in ASP, but not for ASP.NET... i just watched one of the ASP.NET webcasts and it basically explained that very topic =P.. and no you cannot just do html input types without submitting to an ASP page.. they will just submit to nothing. You have to process them somehow.

The reason is because ASP.NET is designed for emulating things like form element memory - so when you submit they retain their values. this functionality is not consistent with submitting to other pages...

However, like i said, a very good workaround is to use the Visible setting. Basically, make each page you have an ASP Panel object, and set the submit button action of each page to hide itself and show the next. Passing values becomes easy as you ALWAYS have access to all the member objects. Also, when objects are hidden, they are actually not loaded into memory, so it's a very efficient method.

Also, if you're uncomfortable with using alternate methods for ASP.NET, just use regular ASP. Your server will still fully support it.I am just going to write regular asp in my .net environment.
If it were a project for a client or so then i would use your method.

I already made a project with a mate of mine, we had to show statistics from an sequel server 2000 db.

We had a search page that was built dynamically (yes we worked with the .visible and .enable property) And when we submitted we used sessions to put the data in. We worked with crystal reports (big ****!) and many other things.

For my site is a pretty 'simple' site i'll just use asp in the .net environment (everything works)

I hope my site wil be done in december. Thx for the tips and i'll use the .enable & .visible properties for another project.Originally posted by darktown
come on this cannot be!!
Anybody else that can say how to pass variables that i submit from the form to another page?

If it's really like this. i am just going to use html input types and use request.form("") on the other page.

really weird way of working i think .. :s

You can , by changing where the form posts to.. by default ASPX pages post to themselves. There is a more detailed MSDN article on how to do this.
 
Back
Top