控件显隐性
<asp:Button ID="btnadd" runat="server" CssClass="buttons" Text="添加" OnClientClick="yc()" OnClick="btnadd_Click" />
<div style="display:none"></div>
首次加载时候,div是隐藏的,点击添加按钮,div出现,再点击,div隐藏,再一次点击他又出现,点击隐藏(通过一个按钮控制)用最简便的方法实现
------解决方案--------------------javascript方法
yc(){
var div1 = document.getElementById("divId");
if(div1.style.display == "none"){
div1.style.display = "block";
}
else if(div1.style.display == "blcok"){
div1.style.display = "none";
}
}
------解决方案--------------------
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (ViewState["x"] == null)
{
Response.Write("第一次点击");
ViewState["x"] = "";
}
else
{
Response.Write("你已经点击过了啊!!!!!!!!!");
}
}
------解决方案--------------------
用jQuery
http://code.01yun.com/javascript/ajax/20110614/54341.html
------解决方案--------------------toggle();函数
------解决方案--------------------<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<div id="Div" runat="server" visible="false">
</div>
protected void Button1_Click(object sender, EventArgs e)
{
if (Div.Visible == true)
{
Div.Visible = false;
}else if(Div.Visible==false){
Div.Visible = true;
}
}
不行么?
------解决方案--------------------jQuery
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".btn1").click(function(){
$("div").toggle();
});
});
</script>
</head>
<body>
<div>This is a paragraph.</div>
<button class="btn1">Toggle</button>
</body>
</html>
------解决方案--------------------