<INPUT id="Password1" style="WIDTH: 140px; BORDER-TOP-STYLE: groove; BORDER-RIGHT-STYLE: groove; BORDER-LEFT-STYLE: groove; HEIGHT: 25px; BORDER-BOTTOM-STYLE: groove" type="password" size="23" name="Password1" runat="server" onkeydown="if(event.keyCode==13)LinkButton1.click()"> Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click '******************** Dim myRBAC As New RBAC.RBAC() Dim CanLogin As Boolean = myRBAC.Login(TextBox1.Text, Password1.Value) If CanLogin Then Response.Redirect("zl/mainframe.aspx") Session("YHMC") = TextBox1.Text Else Response.Write("<script>alert('用户名或密码错误,请重新填写或与管理员联系!')</script>") End If End Sub
还是<input type="password" name="password" runat="server">。CS文件去设置值的时候,都是显示不出来的,为什么??试了楼上两位好心的兄弟的方法,都是不行的但如果分别不设置TextMode="password",跟type设置为text,则设置值跟显示一切OK的是不是。NET不允许对密码框赋值??谢谢
可以
以下是代码:
testVariable.aspx:
-----------------------------
<%@ Page language="c#" Codebehind="testVariable.aspx.cs" AutoEventWireup="false" Inherits="example.testVariable" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>testVariable</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="testVariable" method="post" runat="server">
<asp:textbox id="TextBox1" runat="server" TextMode="Password"></asp:textbox>
<input id="passwd" type="password" runat="server">
</form>
</body>
</HTML>---------------------------------
testVariable.aspx.cs
---------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace example
{
/// <summary>
/// testVariable 的摘要说明。
/// </summary>
public class testVariable : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.HtmlControls.HtmlInputText passwd;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.passwd.Attributes.Add("value","123456");
TextBox1.Text="i love you";
// passwd.Value = "i love html";
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
this.TextBox1.Attributes["value"]="123456";
你可能后来的passwd.Value = "i love html";将前面的结果覆盖了。
那应该怎样在.cs里设置值啊,刚才那个办法好象不行的呀???
'********************
Dim myRBAC As New RBAC.RBAC()
Dim CanLogin As Boolean = myRBAC.Login(TextBox1.Text, Password1.Value)
If CanLogin Then
Response.Redirect("zl/mainframe.aspx")
Session("YHMC") = TextBox1.Text
Else
Response.Write("<script>alert('用户名或密码错误,请重新填写或与管理员联系!')</script>")
End If
End Sub