473,837 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="<%=Reque st.QueryString( "Email")%>" />

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

Regards,

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

protected Email as TextBox

sub page_Load(..)
Email.Text = Request.QuerySt ring("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******** ***********@new s.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="<%=Reque st.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.QuerySt ring["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="<%=Reque st.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.QuerySt ring["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******** ******@TK2MSFTN GP02.phx.gbl...
In 1.x, you'd go into your codebehind and do:

protected Email as TextBox

sub page_Load(..)
Email.Text = Request.QuerySt ring("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:DropDownLi st ID="TypeOfParro t" Runat="server" name="TypeOfPar rot"
class="textbox" >
<asp:ListItem Value="">Please Select</asp:ListItem>
<asp:ListItem Value="Cockatoo ">Cockatoo</asp:ListItem>
<asp:ListItem Value="MaCaw">M aCaw</asp:ListItem>
<asp:ListItem Value="African Grey">African Grey</asp:ListItem>
</asp:DropDownLis t>

So if the Querystring in the URL had domain.com?Parr ot=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="<%=Reque st.QueryString( "Email")%>"
you need to use single quotes or double quotes
value='<%=Reque st.QueryString( "Email")%>'

"Badass Scotsman" <ba************ *@aye.net> wrote in message
news:e4******** ***********@new s.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="<%=Reque st.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='<%=Reque st.QueryString( "Email")%>'

The abovewill work? So close I was afterall.

gary.
May 19 '06 #7
TypeOfParent.Se lectedIndex =
TypeOfParent.It ems.IndexOf(Typ eOfParent.Items .FindByValue(Re quest.Querystri ng("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******** ***********@new s.demon.co.uk.. .

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

protected Email as TextBox

sub page_Load(..)
Email.Text = Request.QuerySt ring("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:DropDownLi st ID="TypeOfParro t" Runat="server" name="TypeOfPar rot"
class="textbox" >
<asp:ListItem Value="">Please Select</asp:ListItem>
<asp:ListItem Value="Cockatoo ">Cockatoo</asp:ListItem>
<asp:ListItem Value="MaCaw">M aCaw</asp:ListItem>
<asp:ListItem Value="African Grey">African Grey</asp:ListItem>
</asp:DropDownLis t>

So if the Querystring in the URL had domain.com?Parr ot=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
1399
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 blah</content> </newspage> How can I use XLink to make an HTML hyperlink out of the "click here" text?
2
1225
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 button to save the changes. Within that button, I refer to dataGrid1.EditItemIndex and it's returning -1. Isn't this property set when I click on the edit button within the grid?
16
1682
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 two kinds of people can make such a comment on C programming. One is C expert with rich experiences of some years on real projects; The other is opportunist idiocy of C programming. What do you think of C programming? Is writing C code an art?...
50
5755
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
4210
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 file (which I can provide if necessary). I use 'Add new Item' and pick 'DataSet'. I believe this creates a TypedDataSet, CORRECT? I take all the defaults as far as Insert, and I pick the advanced tab and ask for Update Statements and Delete...
27
2867
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
1290
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 frames. Left frame (LFRAME) Right frame (RFRAME) Top frame (HFRAME) (and an iframe, called progressbar)
1
1223
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 ID (Done before Auction) Unit Description (Done before Auction) Unit Donor (Done before Auction) Unit Value (Done before Auction)
4
3618
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 (Ņ) as their first character. What creates it? How do we avoid it? Thanks! maria
3
1856
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 Gurtovoy. Iím not doing this because I want to be a Meta Programming guru (because a lot of that stuff looks too crazy for use in the real world). Rather I want to learn heavyweight templates and this is the only
0
9839
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9682
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10564
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6998
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5668
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5846
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4039
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3123
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.