我之前问的一个问题,以为解决了,今天发现没有,重新发起:.net控制前台页面div样式。比如这个DIV的ID为showMsg。我给他指定了2个样式,一个showErrMsg,一个showSucessMsg 。做不同情况下提醒信息显示不同的样式效果。 我知道用JS可以实现,直接用.net后台代码部分,控制代码要怎么写吗?
<div id="showErrMsg" runat="server"> <asp:Label ID="lblErrMsg" runat="server" Text=""> </asp:Label> </div> 样式部分
.showErrMsg
{
padding:5px 5px 5px 25px;
border:1px solid #00BE00;
background:#E6FFE6 url(standard_msg_error.gif) 5px 5px no-repeat;
color:#000;
float:left;
margin:0px;
width:518px;
} .showSucessMsg
{
padding:5px 5px 5px 25px;
border:1px solid #00BE00;
background:#E6FFE6 url(standard_msg_ok.gif) 5px 5px no-repeat;
color:#000;
float:left;
margin:0px;
width:518px;
} 这是我以前的一个问题,当时有人回答//更改为showErrMs样式
showMsg.Style.Add("class","showErrMs");
//更改为showSucessMsg样式
showMsg.Style.Add("class","showSucessMsg");
因为我当时直接定义了样式<div id="showErrMsg" runat="server" class="showErrMs"> <asp:Label ID="lblErrMsg" runat="server" Text=""> </asp:Label> </div> ,也没留意,今天发现了,去掉了定义后,发现后台控制的样式没起到控制效果,根本没效果....请知道的大侠告之~~急~~~~~~~~~
<div id="showErrMsg" runat="server"> <asp:Label ID="lblErrMsg" runat="server" Text=""> </asp:Label> </div> 样式部分
.showErrMsg
{
padding:5px 5px 5px 25px;
border:1px solid #00BE00;
background:#E6FFE6 url(standard_msg_error.gif) 5px 5px no-repeat;
color:#000;
float:left;
margin:0px;
width:518px;
} .showSucessMsg
{
padding:5px 5px 5px 25px;
border:1px solid #00BE00;
background:#E6FFE6 url(standard_msg_ok.gif) 5px 5px no-repeat;
color:#000;
float:left;
margin:0px;
width:518px;
} 这是我以前的一个问题,当时有人回答//更改为showErrMs样式
showMsg.Style.Add("class","showErrMs");
//更改为showSucessMsg样式
showMsg.Style.Add("class","showSucessMsg");
因为我当时直接定义了样式<div id="showErrMsg" runat="server" class="showErrMs"> <asp:Label ID="lblErrMsg" runat="server" Text=""> </asp:Label> </div> ,也没留意,今天发现了,去掉了定义后,发现后台控制的样式没起到控制效果,根本没效果....请知道的大侠告之~~急~~~~~~~~~
解决方案 »
- JQuery+asp.net上传时出现的问题。。高手进!!!!
- 急!急!急!
- 到处exl
- 如何隐藏源文件中 <form name="aspnetForm" method="post" action="Default.aspx" id="aspnet
- 在gridview中的在gridview_RowCreated如何获取单元格的值
- 什么是表单验证
- 提问:一个简单的问题,进来看看吧,小试牛刀嘛!
- datagrid 模板列问题
- 按钮的默认响应设置
- 新手,我装了ASP.NET,也有IIS,但是?急ING
- 为什么装了VS2005后没有首页上没有打开网站,只有打开项目.是在哪里还原设置
- 映射html类型到aspnet_isapi.dll后正常的html却无法访问
如
<input type="text" id="UserName" onchange="CheckUserName();" value="" />
js:
document.getElementById("UserName").className="showErrMs";这样就可以动态定义样式了.
if(成功)
{
div1.visible=true;
div2.visible=false;
}
else
{
div1.visible=false;
div2.visible=true;
}
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.tt{
margin: 55px;
}
</style>
<script type="text/javascript">
function test3()
{
document.getElementById("Text1").className="tt";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="text" onfocus="test3()" /></div>
</form>
</body>
</html>
showErrMsg.Style.Add("background-color","red");
里面的参数不是用来添加class的
关键是我AJAX不是很熟悉,不然无法做到跟数据库互动。所以我选择了去服务端做判断,然后根据结果做不同样式的提示。继续等~~~~
showErrMsg.Style.Add("",""); 这个是添加css样式的
showMsg.Attribute.Add("class","showErrMs");
if (this.checkbox.Checked)
{
upimgbox.Style.Value = "display:block";
}
else if (!this.checkbox.Checked)
{
upimgbox.Style.Value = "display:none";
}