Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Submit form in asp.net


Submit form in asp.net

Reply
  #1 (permalink)  
Old 09-13-03, 06:05 AM
andreasberglind andreasberglind is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Sweden
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Submit form in asp.net

I have these two .aspx pages, default.aspx and answer.aspx.

In the first, I have a form with a dropdown list, and a submit button. What I want is to submit the form to answer.aspx by clicking on the button. Could someone give me some help on this?

PLEASE HELP. Itīs probably really simple, but I donīt hace a clue how.
Reply With Quote
  #2 (permalink)  
Old 09-13-03, 01:32 PM
Mister B.'s Avatar
Mister B. Mister B. is offline
Wannabe Coder
 
Join Date: Jul 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
<FORM METHOD=POST ACTION=URL>
__________________
God save us from the religious fanatics
Reply With Quote
  #3 (permalink)  
Old 09-13-03, 06:32 PM
andreasberglind andreasberglind is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Sweden
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Then what?
This I have done, but it doesnīt work? what else is needed?
Reply With Quote
  #4 (permalink)  
Old 09-14-03, 12:06 AM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
on the other next page put Request.Form("TAG_NAME").
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Reply With Quote
  #5 (permalink)  
Old 11-14-03, 10:44 AM
lunatchi lunatchi is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
This is ASP, not ASP.NET

Hello,
I am just looking for exactly same information, which is how to pass the value to the next page.

<form method=["post" or "get"] action=URL>
According to my research, couple of pages said that action works only for ASP, and not for ASP.NET. Therefore, even you type this line, browser will ignore the command.


<[@o@]> Here is a code behind code, which ask user to key in their name, and
when the button is pressed, it display the value. However, I want to
retrieve the value in another page. But I couldn't find the example.
All the examples I could find so far is same type of code as below,
using only one page.

Can any body help me with this?
Thanks in advance.

FileName: cb1.aspx
<%@ Page Language="cs" Src="cb1.cs" Inherits="HelloWebFormCs"%>
<HTML>
<HEAD>
<title>C# ASP.NET application with "Code Behind"</title>
</HEAD>

<body>
C# ASP.NET application with "Code Behind"<P />
<form runat="server" ID="Form1">
<asp:textbox id="fld1" runat="server" />
<asp:button runat="server" text="Say Hello" ID="Button1" /><br />
<asp:label runat="server" text="" id="TheLabel" />
</form>
</body>
</HTML>




FileName: cb1.cs
public class HelloWebFormCs : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox fld1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label TheLabel;

override protected void OnInit(System.EventArgs e)
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
base.OnInit(e);
}

private void Button1_Click(object sender, System.EventArgs e)
{
TheLabel.Text = "Hello, " + fld1.Text + "(from an ASP.NET/C# WebForm with code behind)";
}
}
Reply With Quote
  #6 (permalink)  
Old 11-14-03, 06:59 PM
psoutham psoutham is offline
New Member
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Pass submitted Values

First off, make friends with MSDN.

You can apporoach this at least two ways...
The First (probably easiest) providing a variable is being passed in the url like http://localhost/nextpage.aspx?fld=myvar:
Code:
FileName: nextpage.cs
public class HelloWebFormCs : System.Web.UI.Page 
{
   protected System.Web.UI.WebControls.Label TheLabel;


   private void Page_Load(object sender, System.EventArgs e) 
   {

     TheLabel.Text = "Hello, " + Server.HtmlEncode(Request.QueryString["fld1"]) + "(from an ASP.NET/C# WebForm with code behind)";

   }
}

The Second is to make use of properties:

formpage.cs
Code:
<snip>
private void Button1_Click(object sender, System.EventArgs e)
{
      Server.Transfer("datapage.aspx");
}

public string Property
{
     get
     {
          return Label1.Text;
     }
}
</snip>
datapage.cs
Code:
public class datapage : System.Web.UI.Page
{
     public formpage sourcepage;
     protected System.Web.UI.WebControls.Label Label1;

     private void Page_Load(object sender, System.EventArgs e)
     {
          if (!IsPostBack)
          {
               sourcepage = (formpage) Context.Handler;
               Label1.Text = sourcepage.Property;
          }
     }
}
It would probably benefit you to download the MSDN Library. Hope I've been helpful.



Quote:
Originally Posted by lunatchi
Hello,
I am just looking for exactly same information, which is how to pass the value to the next page.

<form method=["post" or "get"] action=URL>
According to my research, couple of pages said that action works only for ASP, and not for ASP.NET. Therefore, even you type this line, browser will ignore the command.


...
Reply With Quote
  #7 (permalink)  
Old 11-14-03, 10:07 PM
psoutham psoutham is offline
New Member
 
Join Date: Nov 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
I made an error in my code above...

Instead of this:
Code:
<snip>
public string Property
{
     get
     {
          return Label1.Text;
     }
}
</snip>
It should say:
Code:
<snip>
public string Property
{
     get
     {
          return TextBox1.Text;
     }
}
</snip>
Reply With Quote
  #8 (permalink)  
Old 11-18-03, 05:13 AM
lunatchi lunatchi is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

Your code gave me some idea of where I have been struggling.
Now, I can pass the value to other page, and retrieve them in the different page.
Thank you very very much!!
Reply With Quote
  #9 (permalink)  
Old 11-18-03, 07:33 AM
lunatchi lunatchi is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
To andreasberglind

I think this page gives you some idea about ASP.NET, which describes the differences of ASP and ASP.NET.
First of all, I also used to think in the same way that I can retrieve the data in the same manner as ASP. However, as this page describes that ASP.NET page never accept action even it has been defined as ASP.NET doesn't pass the value to another page. Therefore, always the value obtained in the page have to be processed within the same page... If my understanding is not wrong...
Anyway, I think, this is the page, which answers your questions.

http://www.wimdows.net/articles/article.aspx?aid=8
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Email form in ASP.net andreasberglind ASP.NET 1 05-04-04 06:27 AM
Why I always get \' and \" after I submit the form ! kevin PHP 4 11-24-03 04:57 AM
SQL database registration form help vinhkhuong PHP 3 10-10-03 03:49 AM
asp: URGENT! need to change code to create new form per id seala ASP 2 09-09-03 09:54 PM
Need to submit form to database and text file - Any ideas how? dpreiss ASP 1 08-21-03 06:02 PM


All times are GMT -5. The time now is 01:07 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.