If red.Read() Then Dim tc As FormsAuthenticationTicket tc = New FormsAuthenticationTicket(1, red.GetValue(0).ToString, DateTime.Now, DateTime.Now.AddDays(1), False, "student") Dim encrypt As String = FormsAuthentication.Encrypt(tc) Dim ck As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, encrypt) ck.Expires = DateTime.Now.AddDays(1) Response.Cookies.Add(ck) Dim ru As String = FormsAuthentication.GetRedirectUrl(FormsAuthentication.FormsCookieName, False) Response.Redirect(ru) Label1.Text = User.Identity.Name & User.IsInRole("student") Else Label1.Text = "error1" End If 问题是我看别人的资料是FormsAuthenticationTicket(1, red.GetValue(0).ToString, DateTime.Now, DateTime.Now.AddDays(1), False, "student") 里面的"student"是角色 可我在做的时候 User.IsInRole 是False 但是 User.Identity.Name 的植 又可以取到 该怎么坚决啊忙着搞这个问题了 还没有时间来调这个 等哈揭贴 请大家谅解
现在公布答案 Protected Sub region_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles region.PreRender Dim iten As New ListItem("请选择 ", 0) If region.Items.Contains(iten) Then Else region.Items.Insert(0, New ListItem("请选择 ", 0)) End If End Sub
或者绑定后再add一行.
ADD增加 怎么增加 能够增加到第一项吗
ddl.Items[0].Value="0";
dropdownlist.SelectedItem.Selected = false;
dropdownlist.Items[0].Selected = true;
dropdownlist.Items.Clear();
再绑定
dropdownlist.items.insert(0,new listitem("请选择","value"))
end ifend sub
dropdownlist.items.insert(0,new listitem("请选择","value"))
end ifend sub
tc = New FormsAuthenticationTicket(1, red.GetValue(0).ToString, DateTime.Now, DateTime.Now.AddDays(1), False, "student")
Dim encrypt As String = FormsAuthentication.Encrypt(tc)
Dim ck As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, encrypt)
ck.Expires = DateTime.Now.AddDays(1)
Response.Cookies.Add(ck)
Dim ru As String = FormsAuthentication.GetRedirectUrl(FormsAuthentication.FormsCookieName, False)
Response.Redirect(ru) Label1.Text = User.Identity.Name & User.IsInRole("student")
Else
Label1.Text = "error1"
End If
问题是我看别人的资料是FormsAuthenticationTicket(1, red.GetValue(0).ToString, DateTime.Now, DateTime.Now.AddDays(1), False, "student") 里面的"student"是角色
可我在做的时候 User.IsInRole 是False 但是 User.Identity.Name 的植 又可以取到
该怎么坚决啊忙着搞这个问题了 还没有时间来调这个 等哈揭贴 请大家谅解
dropdownlist.Items.Add(new ListItem("啥?",0));
简单的在里面加一个ITEM谁不会啊问题是他是在数据绑定的时候
该写在什么时候是 DataBinding 还是PreRender 刷新后 会不会有两个
Protected Sub region_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles region.PreRender
Dim iten As New ListItem("请选择 ", 0)
If region.Items.Contains(iten) Then
Else
region.Items.Insert(0, New ListItem("请选择 ", 0))
End If End Sub