473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Very simple question.

Hello,

I have some "runat server" form boxes on the page, for example:

<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="" />

How can I prepopulate this field from the QueryString?

The following creates an error:
<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="<%=Request.QueryString("Email")%>" />

I tried Google but was not really sure how to find the answer.

Regards,

Gary.
May 18 '06 #1
7 1065
In 1.x, you'd go into your codebehind and do:

protected Email as TextBox

sub page_Load(..)
Email.Text = Request.QueryString("Email")
end sub
in 2.0 you could omit the 1st line..

Karl

--
http://www.openmymind.net/

"Badass Scotsman" <ba*************@aye.net> wrote in message
news:e4*******************@news.demon.co.uk...
Hello,

I have some "runat server" form boxes on the page, for example:

<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="" />

How can I prepopulate this field from the QueryString?

The following creates an error:
<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="<%=Request.QueryString("Email")%>" />

I tried Google but was not really sure how to find the answer.

Regards,

Gary.

May 18 '06 #2
Well, typically you would want to keep your markup separate from your code by
using a code-behind approach. And, using this approach it would alleviate
much of your pain.

So, you would be able to do a very simple line of code in the code behind,
perhaps in the Page_Load even handler such as:

Email.Text = Request.QueryString["Email"];
--
-Demetri
"Badass Scotsman" wrote:
Hello,

I have some "runat server" form boxes on the page, for example:

<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="" />

How can I prepopulate this field from the QueryString?

The following creates an error:
<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="<%=Request.QueryString("Email")%>" />

I tried Google but was not really sure how to find the answer.

Regards,

Gary.

May 18 '06 #3
in code behind read the paramater into a mehod variable , then in the
asp page:
codebehind:
public String email = Request.QueryString["Email"];

then in asp page:

value="<%=email%>"

May 18 '06 #4

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:uU**************@TK2MSFTNGP02.phx.gbl...
In 1.x, you'd go into your codebehind and do:

protected Email as TextBox

sub page_Load(..)
Email.Text = Request.QueryString("Email")
end sub
in 2.0 you could omit the 1st line..

Karl

--
http://www.openmymind.net/


Thank you kindly, this worked a treat. Sorry to be a nuisence, could you I
would like to apply the exact same principle to this control:

<asp:DropDownList ID="TypeOfParrot" Runat="server" name="TypeOfParrot"
class="textbox">
<asp:ListItem Value="">Please Select</asp:ListItem>
<asp:ListItem Value="Cockatoo">Cockatoo</asp:ListItem>
<asp:ListItem Value="MaCaw">MaCaw</asp:ListItem>
<asp:ListItem Value="African Grey">African Grey</asp:ListItem>
</asp:DropDownList>

So if the Querystring in the URL had domain.com?Parrot=Cockatoo , the
DropDownList above would default to this value both visually and behind the
scenes.

Any help again appreciated!!

Regards,

Gary.
PS - Really need to learn .net, and fast.
May 18 '06 #5
your quotes are confusing

value="<%=Request.QueryString("Email")%>"
you need to use single quotes or double quotes
value='<%=Request.QueryString("Email")%>'

"Badass Scotsman" <ba*************@aye.net> wrote in message
news:e4*******************@news.demon.co.uk...
Hello,

I have some "runat server" form boxes on the page, for example:

<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="" />

How can I prepopulate this field from the QueryString?

The following creates an error:
<asp:textbox class="textbox" runat="server" type="text" name="Email"
maxlength="200" id="Email" value="<%=Request.QueryString("Email")%>" />

I tried Google but was not really sure how to find the answer.

Regards,

Gary.

May 19 '06 #6
> you need to use single quotes or double quotes
value='<%=Request.QueryString("Email")%>'

The abovewill work? So close I was afterall.

gary.
May 19 '06 #7
TypeOfParent.SelectedIndex =
TypeOfParent.Items.IndexOf(TypeOfParent.Items.Find ByValue(Request.Querystring("Parrot"))

Maybe you should pick up a ASP.NET book or read some online tutorials:
http://asp.net/QuickStart/aspnet/Default.aspx

Karl
--
http://www.openmymind.net/

"Badass Scotsman" <ba*************@aye.net> wrote in message
news:e4*******************@news.demon.co.uk...

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:uU**************@TK2MSFTNGP02.phx.gbl...
In 1.x, you'd go into your codebehind and do:

protected Email as TextBox

sub page_Load(..)
Email.Text = Request.QueryString("Email")
end sub
in 2.0 you could omit the 1st line..

Karl

--
http://www.openmymind.net/


Thank you kindly, this worked a treat. Sorry to be a nuisence, could you
I would like to apply the exact same principle to this control:

<asp:DropDownList ID="TypeOfParrot" Runat="server" name="TypeOfParrot"
class="textbox">
<asp:ListItem Value="">Please Select</asp:ListItem>
<asp:ListItem Value="Cockatoo">Cockatoo</asp:ListItem>
<asp:ListItem Value="MaCaw">MaCaw</asp:ListItem>
<asp:ListItem Value="African Grey">African Grey</asp:ListItem>
</asp:DropDownList>

So if the Querystring in the URL had domain.com?Parrot=Cockatoo , the
DropDownList above would default to this value both visually and behind
the scenes.

Any help again appreciated!!

Regards,

Gary.
PS - Really need to learn .net, and fast.

May 19 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gene Ellis | last post by:
Very simple question. If I have the XML file below: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="newspage.xsl"?> <newspage> <content>Click here for blah...
2
by: James | last post by:
I have a very simple datagrid, with an edit button that I added in PropertyBuilder. This fires the EditCommand event just fine and I show a panel where the user can edit certain fields. I have a...
16
by: lovecreatesbeauty | last post by:
`Writing C code is very simple', one guy related to my work said. I'm not sure whether he is an expert or not. What he said about C programming like this can't convince me. I think there should be...
50
by: diffuser78 | last post by:
I have just started to learn python. Some said that its slow. Can somebody pin point the issue. Thans
2
by: dave | last post by:
Hi, I have searched for the answer for this error message without success. I have seen the question many times though:) I create an ASP.NET project (VS 2005, C#), and use a very simple .mdf...
27
by: Paulo da Silva | last post by:
Hi! I was told in this NG that string is obsolet. I should use str methods. So, how do I join a list of strings delimited by a given char, let's say ','? Old way:
1
by: Simon | last post by:
A very simple question that is very hard to google..(so please be so kind to answer it, if you have the answer.) How can I reach an iframe, located in another frame. Situation: frameset of three...
1
by: Raycaster | last post by:
I'm 3/4 finished 2 simple VB apps for a upcoming silent auction being held at my children's school. Very Simple - This is what it does: 1st app allows input and builds a text database Unit...
4
by: maria | last post by:
I only use C++ with Visual Studio 6.0 for string manipulations in thousands of HTML pages on my website. Many times, the output files of many of my C++ programs contain a spanish question mark (¿)...
3
by: stdlib99 | last post by:
Hi, I have a simple question regarding templates and meta programming. I am going to try and work my way through the C++ Template Metaprogramming, a book by David Abrahams and Aleksey...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.