这是登陆后隐藏button的控件 我运行的时候总说页面有错误 也不说什么错误 大神们帮我看看
<script type="text/javascript"> function fdenglu()
{
if (Session("user_name")=Null)
{
//document.getElementById("Button1").style .visibility ='hidden';
var denglu1=document.getElementById("Button1").style .visibility ='visible'; // document.getElementById("Button2").style .visibility ='hidden';
// document.getElementById ("Button9").style .visibility ='visible';
}
else
var denglu2=document.getElementById ("Button1").style .visibility ='hidden';
}
function fzhuce()
{
if (Session("user_name")=Null)
var zhuce1=document.getElementById ("Button2").style .visibility ='visible';
else
var zhuce2=document.getElementById ("Button2").style .visibility ='hidden';
}
function fzhuxiao()
{
if (Session("user_name")=Null)
var zhuxiao1=document.getElementById ("Button9").style .visibility ='hidden';
var zhuxiao2=document.getElementById ("Button9").style .visibility ='visible';
}
</script>
<input type="button" id ="Button1" value= "登陆" onclick ="fdenglu()"&"Button1_Click" />
<input type="button" id ="Button2" value= "注册" onclick ="fzhuce()"&"Button2_Click" />
<input type="button" id ="Button9" value= "注销" onclick ="fzhuxiao()"&"Button9_Click"/>
<script type="text/javascript"> function fdenglu()
{
if (Session("user_name")=Null)
{
//document.getElementById("Button1").style .visibility ='hidden';
var denglu1=document.getElementById("Button1").style .visibility ='visible'; // document.getElementById("Button2").style .visibility ='hidden';
// document.getElementById ("Button9").style .visibility ='visible';
}
else
var denglu2=document.getElementById ("Button1").style .visibility ='hidden';
}
function fzhuce()
{
if (Session("user_name")=Null)
var zhuce1=document.getElementById ("Button2").style .visibility ='visible';
else
var zhuce2=document.getElementById ("Button2").style .visibility ='hidden';
}
function fzhuxiao()
{
if (Session("user_name")=Null)
var zhuxiao1=document.getElementById ("Button9").style .visibility ='hidden';
var zhuxiao2=document.getElementById ("Button9").style .visibility ='visible';
}
</script>
<input type="button" id ="Button1" value= "登陆" onclick ="fdenglu()"&"Button1_Click" />
<input type="button" id ="Button2" value= "注册" onclick ="fzhuce()"&"Button2_Click" />
<input type="button" id ="Button9" value= "注销" onclick ="fzhuxiao()"&"Button9_Click"/>
"="是赋值
"=="才能判断
那全部代码如下:
<%@ 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 Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Log-in.aspx")
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Register1.aspx")
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Happy.aspx")
End Sub
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Angry.aspx")
End Sub
Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Sad.aspx")
End Sub
Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Awkward.aspx")
End Sub
Protected Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("Others.aspx")
End Sub
Protected Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("HOT.aspx")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'之前应有个登陆的判断 否则会一直显示欢迎你 和 登陆按钮
Dim user_name As String
user_name = Session("user_name")
Label1.Text = user_name & "欢迎你!"
End Sub
</script>
<script type="text/javascript">
// set conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & MapPath("database.mdb"));
function fdenglu()
{
if (Session("user_name")=Null)
{
var denglu1=document.getElementById("Button1").style .visibility ='visible'; }
else
var denglu2=document.getElementById ("Button1").style .visibility ='hidden';
}
function fzhuce()
{
if (Session("user_name")=Null)
var zhuce1=document.getElementById ("Button2").style .visibility ='visible';
else
var zhuce2=document.getElementById ("Button2").style .visibility ='hidden';
}
function fzhuxiao()
{
if (Session("user_name")=Null)
var zhuxiao1=document.getElementById ("Button9").style .visibility ='hidden';
var zhuxiao2=document.getElementById ("Button9").style .visibility ='visible';
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>杂味</title>
<style type="text/css">
<!--
.STYLE2 {font-size: small}
-->
</style>
</head><body>
<form id="Form1" runat="server">
<div style="text-align: center; background-image: url(Images/Main/BackColor.jpg);">
<table border="1" style="border-right: thin groove; border-top: thin groove; border-left: thin groove;
border-bottom: thin groove" width="948" >
<tr>
<td style="width: 900px; position: static; height: 55px; border-right: #99cccc 0px solid; border-top: #99cccc 0px solid; border-left: #99cccc 0px solid; border-bottom: #99cccc 20px solid; text-align: right;" valign="middle">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<input type="button" id ="Button1" value= "登陆" onclick ="fdenglu()"&"Button1_Click" />
<input type="button" id ="Button2" value= "注册" onclick ="fzhuce()"&"Button2_Click" />
<input type="button" id ="Button9" value= "注销" onclick ="fzhuxiao()"&"Button9_Click"/>
</td>
</tr>
<tr>
<td style="width: 900px; height: 431px; position: static; background-image: url(Images/Main/BackColor1.jpg); border-right: #99cccc 0px solid; border-top: #99cccc 0px solid; border-left: #99cccc 0px solid; border-bottom: #99cccc 0px solid;" valign="middle">
<br />
<br />
<asp:Button ID="button3" runat="server" Text="喜" Font-Bold="True" Font-Size="XX-Large" Height="50px" Width="50px" BackColor="Transparent" OnClick="Button3_Click" />
<asp:Button ID="Button4" runat="server" Text="怒" Font-Bold="True" Font-Size="XX-Large" Height="50px" Width="50px" BackColor="Transparent" OnClick="Button4_Click"/>
<asp:Button ID="Button5" runat="server" Text="哀" Font-Bold="True" Font-Size="XX-Large" Height="50px" Width="50px" BackColor="Transparent" OnClick="Button5_Click" />
<asp:Button ID="Button6" runat="server" Text="囧" Font-Bold="True" Font-Size="XX-Large" Height="50px" Width="50px" BackColor="Transparent" OnClick="Button6_Click"/><br />
<asp:Button ID="Button7" runat="server" Text="杂味" Font-Bold="True" Font-Size="Small" Height="39px" Width="46px" BackColor="Transparent" OnClick="Button7_Click"/>
<asp:Button ID="Button8" runat="server" Text="HOT!" Font-Bold="True" Font-Size="Small" Height="39px" Width="42px" BackColor="Transparent" OnClick="Button8_Click"/>
</td>
</tr>
<tr>
<td style="width: 900px; position: static; height: 51px; border-right: #99cccc 0px solid; border-top: #99cccc 0px solid; font-size: 10pt; border-left: #99cccc 0px solid; border-bottom: #99cccc 0px solid;" valign="middle">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
或者告诉我别的可能实现的方法
其实我做web的语言是vb
var sessionName=<%=Session("user_name")%>function fdenglu()
{
if (sessionName == null)
.......
</script>
你可以页面加载的时候 用个隐藏域保存登录状态 。
If Session("user_name") Is Nothing Then
Button1.Visible = True
Button2.Visible = True
Button9.Visible = False
Else
Button1.Visible = False
Button2.Visible = False
Button9.Visible = True就可以完成 谢谢大家的回答啊