Thursday, March 29, 2012

Login- demo

I have a login control which I want to have loaded my demo user name and the
demo password. Naturally the demo password doesnt have to show as text
literal but best I can tell I cant set the password programmically. I could
hide the password however I would still need to "login" this demo user with a
password so either I need to find away to set the password in the textbox or
login the demo user programmically.

Thanks!Hi Dean,

For a demo password you can use a little client-side JavaScript to pre-fill
the fields.

Here's a little example below. Note however that the client-side ID of the
controls will change depending on whether the login is in a master page
and/or user control.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
If Not IsPostBack Then
Dim sb As New StringBuilder
sb.Append("var uname=document.getElementById")
sb.Append("('Login1_UserName');")
sb.Append("uname.value='usernameID';")
sb.Append("var pwd=document.getElementById")
sb.Append("('Login1_Password');")
sb.Append("pwd.value='thepassword';")
ClientScript.RegisterStartupScript _
(Me.GetType, "lgin", sb.ToString, True)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Script login</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:login id="Login1" runat="server">
</asp:login>
</div>
</form>
</body>
</html>

"Sean" <Sean@.discussions.microsoft.comwrote in message
news:E5B47437-A359-4B51-8B06-AF51E0D10DB5@.microsoft.com...

Quote:

Originally Posted by

>I have a login control which I want to have loaded my demo user name and
>the
demo password. Naturally the demo password doesnt have to show as text
literal but best I can tell I cant set the password programmically. I
could
hide the password however I would still need to "login" this demo user
with a
password so either I need to find away to set the password in the textbox
or
login the demo user programmically.
>
Thanks!

0 comments:

Post a Comment