473,289 Members | 1,953 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,289 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 1060
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.