Newbie question

L

Lee Alexander

I'm trying to get a plain vanilla form post to work separate from the view
state stuff. So I started a new Website via Visual Studio 2005 and turned
off the ViewState for the default page by using EnableViewState="false",
then I added the following HTML to the asp page:

<form method="POST" action="Default.aspx" id="formId"
enctype="text/plain">
<input type="text" name="blah" />
<input type="submit" value="Submit" />
</form>

followed by some code in the pageload method:

protected void Page_Load(object sender, EventArgs e)
{
string s = this.Request.Form.Get( "blah" );
System.Diagnostics.Debug.WriteLine( s );
}

The problem is that I never get 'blah' coming through after submitting the
form. I'm sure i'm doing something really stupid here, could anyone put me
our of my misery???


Regards
Lee
 
D

Daniel Fisher\(lennybacon\)

protected void Page_Load(object sender, EventArgs e)
{
string s = this.Request.Form["blah"];
System.Diagnostics.Debug.WriteLine( s );
}

But you should use

<form method="POST" action="Default.aspx" id="formId"
enctype="text/plain">
<asp:TextBox ID="blah" runat="server" />
< asp:Button ID="submit" runat="server" Text="Submit" />
</form>

And

protected void Page_Load(object sender, EventArgs e)
{
string s = this.blah.Text;
System.Diagnostics.Debug.WriteLine( s );
}

--Daniel
http://staff.newtelligence.com/danielf/




-----Original Message-----
From: Lee Alexander [mailto:lee@NoSpamPlease_Digita.com]
Posted At: Tuesday, January 17, 2006 9:10 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Newbie question
Subject: Newbie question

I'm trying to get a plain vanilla form post to work separate from the
view
state stuff. So I started a new Website via Visual Studio 2005 and
turned
off the ViewState for the default page by using EnableViewState="false",

then I added the following HTML to the asp page:

<form method="POST" action="Default.aspx" id="formId"
enctype="text/plain">
<input type="text" name="blah" />
<input type="submit" value="Submit" />
</form>

followed by some code in the pageload method:

protected void Page_Load(object sender, EventArgs e)
{
string s = this.Request.Form.Get( "blah" );
System.Diagnostics.Debug.WriteLine( s );
}

The problem is that I never get 'blah' coming through after submitting
the
form. I'm sure i'm doing something really stupid here, could anyone put
me
our of my misery???


Regards
Lee
 
L

Lee Alexander

Yes but i wanted just to use a standard Html input control. Can't I use them
with a form POST in ASP.NET then?

Note I have EnableViewState="false" set on the page.

Regards
Lee
 
R

Raymond

Use:
Response.Write( Request.Form["blah"]);

instead of the Debug.WriteLine().

It does come through.
 
L

Lee Alexander

The collection was empty when i was debugging it (on the submit). The
diagnostics.Writeline was so i could see something in the debugger output
window, equally I could have put it in the response. I don't see the
difference since the collection was empty anyway....

Regards
Lee

Raymond said:
Use:
Response.Write( Request.Form["blah"]);

instead of the Debug.WriteLine().

It does come through.

Lee Alexander said:
I'm trying to get a plain vanilla form post to work separate from the
view
state stuff. So I started a new Website via Visual Studio 2005 and turned
off the ViewState for the default page by using EnableViewState="false",
then I added the following HTML to the asp page:

<form method="POST" action="Default.aspx" id="formId"
enctype="text/plain">
<input type="text" name="blah" />
<input type="submit" value="Submit" />
</form>

followed by some code in the pageload method:

protected void Page_Load(object sender, EventArgs e)
{
string s = this.Request.Form.Get( "blah" );
System.Diagnostics.Debug.WriteLine( s );
}

The problem is that I never get 'blah' coming through after submitting
the
form. I'm sure i'm doing something really stupid here, could anyone put
me
our of my misery???


Regards
Lee
 
R

Raymond

That's because you've set the enctype to text/plain.
Remove it, and the collection will come through.


Lee Alexander said:
The collection was empty when i was debugging it (on the submit). The
diagnostics.Writeline was so i could see something in the debugger output
window, equally I could have put it in the response. I don't see the
difference since the collection was empty anyway....

Regards
Lee

Raymond said:
Use:
Response.Write( Request.Form["blah"]);

instead of the Debug.WriteLine().

It does come through.

Lee Alexander said:
I'm trying to get a plain vanilla form post to work separate from the
view
state stuff. So I started a new Website via Visual Studio 2005 and turned
off the ViewState for the default page by using EnableViewState="false",
then I added the following HTML to the asp page:

<form method="POST" action="Default.aspx" id="formId"
enctype="text/plain">
<input type="text" name="blah" />
<input type="submit" value="Submit" />
</form>

followed by some code in the pageload method:

protected void Page_Load(object sender, EventArgs e)
{
string s = this.Request.Form.Get( "blah" );
System.Diagnostics.Debug.WriteLine( s );
}

The problem is that I never get 'blah' coming through after submitting
the
form. I'm sure i'm doing something really stupid here, could anyone put
me
our of my misery???


Regards
Lee
 
L

Lee Alexander

Raymond,

Cheers your a star!!!! That worked a treat.

Thanks again
Lee

Raymond said:
That's because you've set the enctype to text/plain.
Remove it, and the collection will come through.


Lee Alexander said:
The collection was empty when i was debugging it (on the submit). The
diagnostics.Writeline was so i could see something in the debugger output
window, equally I could have put it in the response. I don't see the
difference since the collection was empty anyway....

Regards
Lee

Raymond said:
Use:
Response.Write( Request.Form["blah"]);

instead of the Debug.WriteLine().

It does come through.

I'm trying to get a plain vanilla form post to work separate from the
view
state stuff. So I started a new Website via Visual Studio 2005 and turned
off the ViewState for the default page by using EnableViewState="false",
then I added the following HTML to the asp page:

<form method="POST" action="Default.aspx" id="formId"
enctype="text/plain">
<input type="text" name="blah" />
<input type="submit" value="Submit" />
</form>

followed by some code in the pageload method:

protected void Page_Load(object sender, EventArgs e)
{
string s = this.Request.Form.Get( "blah" );
System.Diagnostics.Debug.WriteLine( s );
}

The problem is that I never get 'blah' coming through after submitting
the
form. I'm sure i'm doing something really stupid here, could anyone
put
me
our of my misery???


Regards
Lee
 

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