Showing posts with label enter. Show all posts
Showing posts with label enter. Show all posts

Monday, March 26, 2012

Passing Variable to new Page

How do I pass a string to a new page.

For example I want to have a person enter their name and hit submit.
After hiting submit, the name is entered into a database and a confirmation page with the person's name is dislayed.

How do I do this?The simplest way, is with a querystring - -

response.redirect ("newpage.aspx?name=" & txtName.text)

Then, in the new page, just capture the querystring:

Dim sName as string
sName=request.querystring

From there, you can use the variable 'sName' anywhere you'd like on the page, as long as it's dimmed globally to the page (outside any events)
If u want the variable to be used only in one page Querystring is the best choice.If u want to hold the value for many pages, use Sessions.
Thanks,
Kumar.
Thanks. It's perfect.
Okay...I'm dumb..where do I declare the variable Dim strName?
I'm using Webmatrix. Do I delare them in the at the to of the html code or from the code section?

eg.<%declare here%>
in the code section...


Dim strName as string = Request.QueryString("Vari1")


HTH

Saturday, March 24, 2012

Passing variables between pages

Hello, I have a page where I ask the user to enter text into a text box, and clicking a button which sends them to another page. I am using the code (in C#):

void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("results.aspx?q=" + TextBox1.Text);
}

which works fine, but how would I call upon the variable in the results page? Also, how could I check the TextBox1.Text to see if it is blank? I tried:

If (TextBox1.Text = "")

but it tells me that I can't change from a string to a bool. Any help would be great, thanks.Well, in VB to check for empty strings I do this.

If TextBox1.Text Is String.Empty Then
' Yell at the person for not entering any text
Else
' Thank them for entering something
End If

Friday, March 16, 2012

Password length

i want the user to enter the password length of atleast 7 charaters.

so how to user any validators for that vs.net 2003 framwork 1.1 iam using

Use a regular expression validator with this regex (minimum 7 characters, maximum of 50):

[\w\s]{7,50}


Have a javascript function which will validate the length of textbox. If the textbox is less than 7 characters, alert a message. Check the length after trimming the length of the textbox.

Call this function inONBLUR event of textbox.


Why you don't use server web asp.netvalidating controls ...