Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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:
ASP.NET
<%@ 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>
Posted
Updated 13-May-20 17:30pm
v2
Comments
Sergey Alexandrovich Kryukov 10-Jul-12 1:35am    
CSS (style sheet) or a style?
--SA
sahabiswarup 10-Jul-12 1:58am    
Sergey Alexandrovich Kryukov i want to apply 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.

C#
.modalBackground
{
    background-color:
    filter:alpha(opacity=70);
    opacity:0.7;
}


For more information look at below links:

Modal Popup Extender Basics[^]
ModalPopup Extender[^]
 
Share this answer
 
Comments
sahabiswarup 10-Jul-12 1:20am    
Thanks for you reply; i have used above code to apply css in modal popup extender.
But it is not working in web user control.
Jim Jos 10-Jul-12 1:43am    
The web user control is your own control? Please provide the code for that control also..
sahabiswarup 10-Jul-12 1:44am    
Here is my web user control code

<%@ 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-top:50px;">
</td>
<td style="background:url(../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>
Vani Kulkarni 10-Jul-12 2:15am    
Try keeping modalBackground CSS class in this page for testing purpose, see if it works.
sahabiswarup 10-Jul-12 5:14am    
I have also try your mentioned method but it doesn't work.
VS2010 adds this DOCTYPE by default -
Quote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Change it to
Quote:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

This solves the issue. Stylesheet gets applied properly !!!
 
Share this answer
 
Comments
Vani Kulkarni 10-Jul-12 6:03am    
Interesting did not know about this.
sahabiswarup 10-Jul-12 7:17am    
it works..[:)]
include your css file to master page or main page which is contain web user control thats it...
 
Share this answer
 
in .ascx
ASP.NET
<link href="../css/style.css" rel="stylesheet" type="text/css" runat="server" id="linkCSS1" />


in .cs Page_Load
C#
linkCSS1.Attributes("href") = ResolveUrl(linkCSS1.Attributes("href"));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900