如何在Web用户控件中添加CSS [英] how to add css in web user control
问题描述
我正在使用Web用户控件,并且有一个模式弹出窗口,我想将CSS添加到模式弹出窗口.
我已经用谷歌搜索了这个话题,但没有得到任何富有成效的答案.请给我一些适当的解决方案,通过该解决方案,我可以使用CSS进行Web用户控制.
提前致谢.代码如下:
i am using a web user control and there is a modal popup, i want to add css to the modal popup.
i have googled this topic but haven''t get any fruitful answer. Please give me some proper solution through which i can use css to web user control.
Thanks in advance. Code given below:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PopupLoginControl.ascx.cs"
Inherits="Ajax_PopupLoginControl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<script type="text/css" src="<%= ResolveUrl("../css/style.css") %>"></script>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<ajaxtoolkit:ModalPopupExtender BackgroundCssClass="modalBackground" CancelControlID="btnClose" runat="server" PopupControlID="Panel1" ID="ModalPopupExtender1" TargetControlID="btnShowPopup" />
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" DefaultButton="btnOk">
<table width="100%" border="0" cellpadding="2" cellspacing="5">
<tr >
<td style="width:35%;padding-removed50px;"> </td>
<td style="background:removed(../images/item_box.gif) repeat-x;">
<asp:Label id="labMsg" runat="server" /> Username : admin Password : admin
</td>
</tr>
<tr>
<td align="right" valign="middle"> Email Id : </td>
<td>
<asp:TextBox ID="txtLogin" runat="server">
</td>
</tr>
<tr>
<td align="right" valign="middle"> Password : </td>
<td>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password">
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnOk" OnClick="Login" runat="server" Text="Sign In" />
<asp:Button ID="btnClose" runat="server" Text="Cancel" />
</td>
</tr>
</table>
推荐答案
我假设您使用的是 AJAX控制工具包中的 Modal Popup Extender .将以下属性添加到您的模式弹出窗口:
BackgroundCssClass ="modalBackground"
CSS 可以在您的 CSS类中定义,并可以在上述属性中引用.
I am assuming that you are using Modal Popup Extender from AJAX Control Toolkit. Add below property to your Modal Popup:
BackgroundCssClass="modalBackground"
CSS can be defined in your CSS Class and referred in the above property.
.modalBackground
{
background-color:
filter:alpha(opacity=70);
opacity:0.7;
}
有关更多信息,请参见以下链接:
Modal Popup Extender Basics [ ModalPopup扩展器 [
For more information look at below links:
Modal Popup Extender Basics[^]
ModalPopup Extender[^]
VS2010默认情况下添加此DOCTYPE-
VS2010 adds this DOCTYPE by default -
<!DOCTYPE html PUBLIC-//W3C//DTD XHTML 1.0 Transitional//EN""http://www. w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
更改为
Change it to
<!DOCTYPE html PUBLIC-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
这样就解决了这个问题.样式表已正确应用!!!
This solves the issue. Stylesheet gets applied properly !!!
将您的css文件包括到母版页或包含Web用户控件的主页中...
include your css file to master page or main page which is contain web user control thats it...
这篇关于如何在Web用户控件中添加CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!