Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP User Control 1

Status
Not open for further replies.

robertborchardt

Programmer
Mar 30, 2010
3
US
I have two text boxes (passwordLength and pwd)and a button1. I have placed the code in the source <script> and I have used a button1 click sub but I cannot get the data to show up on the pwd text field. The code is below. What am I missing?


Public Sub Button1_Click((ByVal passwordLength As Integer) Handles Button1.Click
Dim passwordLength As Integer
Dim pwd As String
Dim permittedChars As String
permittedChars = "abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789"
pwd = ""
For i = 1 To passwordLength
pwd = pwd & Mid(permittedChars, Int(Rnd() * Len(permittedChars) + 1), 1)

Next i

End Sub
 
OK, a few issues:

1. You are just appending data to a variable - nowhere do you write that variable back out to a control on the page.
2. If you are going to append text to a string, use the StringBuilder class as it is much more efficient
3. If you are just trying to generate a random password, check out the Membership.GeneratePassword function
4. If you are writing server-side code, it will make it easier to maintain if you put it in a code behind file.

Mark,

Darlington Web Design[tab]|[tab]Experts, Information, Ideas & Knowledge[tab]|[tab]ASP.NET Tips & Tricks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top