ASP.Net Form Posting

A

av

hi,I have couple of Questions regarding the ASP.NET.

Post the Values from WebPage1.aspx to WebPage2.aspx

The code i have is in webpage1.aspx
<form action="webpage2.aspx" method=post runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
How is the Post done using Button Server Control ?? in
Regular ASP v use the <Input and set the type to sumbit>
for the post to occur !
I am able to add <Script> tags but the content is not
executed !! I tried to use the onclik() event which i
wrote in the <script> for the Button, but it doesnt seem
to wrok.

If i have the Server Controls i am not able to post the
form.
if i remove the "runat=server" from the FORM tag and
replace the <asp> controls with <input> regular HTML
controls the post works.

Please let me know where exactly the problem is . ...early
response is appericiated !!!
 
C

Chris Jackson

The form is set to post back to itself once you start using server controls.
You need to fundamentally change how you work with web applications. Instead
of using a second page, use the same page and check the Form.IsPostBack
value to determine what you are doing at the time. Then, you can work with
the controls that you declared in the code behind in order to read. It's an
object oriented design paradigm now.

So, assuming you are collecting from two text boxes:

1. Set up declarations of both text boxes in the code behind
2. In the pageload event, check to see if you are in post back
3. If so, then you can get the values of the controls using the local
variables you have and write them to the database
4. Once you are done, you can response.redirect or server.transfer to
another page, or whatever you want to do next.

Everything is kept together and is neatly declared as objects - it takes
some getting used to if you are used to ASP Classic, but once you get used
to it you'll like it a lot better.
 
A

av

Thanks chris for the info.. Any good books or white papers
which gives me the precise info like managing sessions,
the current application i am using Session UserName and
Pwd validation from a COM object.. any better suggestion
on handling session i mean to use ASP.net features ?
and other quesiton on the <script> tags.. for some reason
i am getting an execption on namespace.. please let me
know on this.... thanks once again for prompt response...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top