I am using the Ajax Modal Popup Extender to display a panel as a modal popup. I've applied a CSS class to the panel and everything displays fine. However, when I add the BackgroundCssClass property to my popup extender, the border on my panel does not show up. The modal background displays properly and everything else in the panel remains the same, but I can't get the border to display. What might be causing this?
**CSS**
.PopupPanel
{
width: 75%;
height: 55%;
text-align: center;
padding: 5px;
overflow: auto;
border-style: solid;
border-width: 8px;
border-color: #0055A5;
background-color: White;
}
.ModalBackground
{
background-color: rgba(170,170,174,0.5);
}
**ASPX**
<asp:Panel ID="InputPanel" runat="server" CssClass="PopupPanel">
<asp:Label ID="HeaderLabel" runat="server"
Text="[text here]"
Font-Size="Large"></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Width="85%"
Height="65%" Wrap="False"></asp:TextBox>
<br />
<asp:Button ID="okButton" runat="server" Text="Submit"
CssClass="genericButton" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel"
CssClass="genericButton" />
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
PopupControlID="InputPanel" TargetControlID="PasteButton"
BackgroundCssClass="ModalBackground" PopupDragHandleControlID="HeaderLabel">
</ajaxToolkit:ModalPopupExtender>
Related
Hello!
Can anyone tell me how can I place any Gridview in center in Div or panel? I have applied following CSS but its does not working:
<asp:Panel ID="pnlGrid" CssClass="panel" runat="server">
<div style="text-align:center">
<asp:GridView ID="grdReqApproval" runat="server" AutoGenerateColumns="false" CssClass="SimpleGrid">
<Columns>
<asp:BoundField DataField="Approved By" HeaderText="Approved By" />
<asp:BoundField DataField="User Name" HeaderText="User Name" />
<asp:BoundField DataField="Approval Time" HeaderText="Approvel Time" />
</Columns>
</asp:GridView>
</div>
</asp:Panel>
.panel
{
width: 330px;
padding: 10px;
min-height: 20px;
border: 1px solid #dcdcdc;
margin-left:auto;
margin-right:auto;
}
HorizontalAlign property of Gridview can solve your problem
<asp:Panel ID="pID" runat="server">
<div>
<asp:GridView ID="gvID" runat="server" AutoGenerateColumns="false"
HorizontalAlign="Center">
<Columns>
...
...
</Columns>
</asp:GridView>
</div>
Check this is working for me , Ultimatly gridview get converted to table so the apply following stylesheet to your gridview which i applied to table
CSS
.centered-table {
margin-left: auto;
margin-right: auto;
}
HTML
<div>
<table class="centered-table" border="1">
<tr><td>Pekin</td> <td>Illinois</td></tr>
<tr><td>San Jose</td><td>California</td></tr>
</table>
</div>
JsFiddle Demo
Slight case of thread necromancy, but I was having the same problem and managed to fix it by aligning the code block rather than the gridview itself.
Basically I set the width of the element to 40%, and left to 30% (which means right is also 30%, because maths) and that positions the whole lot, text, grid and all into the middle of the page.
The css looks roughly like this
GridExample
{
position:absolute;
left:30%;
width:40%;
padding:0;
margin:0;
}
on your div text-align: center
as you see here, your class works. Just be sure its parent container is wider so it can center
http://jsfiddle.net/C7ybw/
#container{
width:800px;
border:1px solid #000;
}
.div_text_center {
text-align: center;
margin-left: auto;
margin-right: auto;
}
<div class="div_text_center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:GridView ID="GridView1" runat="server" HorizontalAlign="Center">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
I'm trying to use a radio button list to change some label texts in an update panel, but for whatever reason the SelectedIndexChanged event seems to only fire the first time and then never again. I've Googled and Googled but everything I've found to try has had no luck fixing the issue.
Autopostback is set to true, I've tried both the standard .net ScriptManager and the ToolkitScriptManager, both act the same, I've tried specifying the Event in the Trigger and having it unspecified (which falls back on the default for that control type) ... I've also tried binding the rbl in a if not me.ispostback then... structure for the page load event.
The VB I'm using in the event is just a simple If this index is selected, label.text="whatever" else "yadda" ... nothing fancy at all. It all works great if the Update panel isn't in play, except I was hoping to get rid of the screen flash from a full postback. I'm sticking the meat & potatoes of my asp.net below...Help!
Type1
Type2
<asp:Panel ID="DesignInfoHeaderPanel" runat="server" CssClass="headerpanel">
<asp:Label ID="lblDesignInfo" runat="server" font-bold="true"
style="z-index: 1; left: 5px; top: 5px; position: absolute" Text="Design Information"></asp:Label>
</asp:Panel>
<div class="cpdiv">
<asp:Panel ID="DesignInfoPanel" runat="server" CssClass="collapsepanel">
<asp:UpdatePanel runat="server" ID="DIUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" font-bold="true"
style="z-index: 1; left: 5px; top: 7px; width: 95px; position: absolute; text-align: right"
Text="Account Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Font-Names="Verdana" Font-Size="8pt"
style="z-index: 1; left: 110px; top: 4px; width: 144px; position: absolute"></asp:TextBox>
<asp:Label ID="Label2" runat="server" font-bold="true"
style="z-index: 1; left: 270px; top: 7px; width: 140px; position: absolute"
Text="Est. Volume (# units)"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Font-Names="Verdana" Font-Size="8pt"
style="z-index: 1; left: 415px; top: 4px; width: 60px; position: absolute"></asp:TextBox>
<asp:Label ID="Label3" runat="server" font-bold="true"
style="z-index: 1; left: 7px; top: 35px; width: 95px; position: absolute; text-align: right"
Text="Sales Manager"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Font-Names="Verdana" Font-Size="8pt"
style="z-index: 1; left: 110px; top: 32px; width: 150px; position: absolute">
</asp:DropDownList>
<asp:Label ID="Label4" runat="server" font-bold="true"
style="z-index: 1; left: 485px; top: 7px; width: 140px; position: absolute"
Text="Personalization Type"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" Font-Names="Verdana" Font-Size="8pt"
style="z-index: 1; left: 630px; top: 4px; width: 150px; position: absolute">
</asp:DropDownList>
<asp:CheckBox ID="CheckBox1" runat="server" font-bold="true"
style="z-index: 1; left: 298px; top: 32px; position: absolute" Text="Rental"
TextAlign="Left" />
<asp:CheckBox ID="CheckBox2" runat="server" font-bold="true"
style="z-index: 1; left: 397px; top: 32px; position: absolute" Text="Dir Sales"
TextAlign="Left" />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" BorderColor="#640000"
BorderStyle="Solid" BorderWidth="2px" Font-Bold="true"
RepeatDirection="Horizontal"
style="z-index: 1; left: 545px; top: 28px; position: absolute"
TextAlign="Left">
<asp:ListItem Value="0">Type1</asp:ListItem>
<asp:ListItem Value="1">Type2</asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rblEmblemType" />
</Triggers>
</asp:UpdatePanel>
It could be because UpdatePanel is Updating. Since You have not post any information about your Code-Script, I assume that you have not used The following code in your Event Method.
UpdatePanel1.Update()
This(The Following One) is a less chance that could happen.
You don't need to use asyncPostBackTrigger if you use AutoPostBack..! You need to use trigger when an Image Button/Image/Grid..etc Event happens which or this Error Occurs
The message received from the server could not be parsed.
Try to add ClientIDMode="AutoID" to your RadioButtonList.
My code and yours are very similar.
In my cases, SelectedIndexChanged events are fired when I set PostBackTrigger.
Actually, Event fires only once means click events are attached the other Radio buttons (which is not selected).
So, I simply solved to delete "Selected=true"
I've been struggling with this asp.net Menu control problem for days and it's driving me crazy. Here the code:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal" CssClass="hrMainMenu" DynamicHorizontalOffset="1" >
<DynamicHoverStyle ForeColor="White" Font-Bold="True" />
<DynamicMenuItemStyle ForeColor="White" />
<DynamicMenuStyle Width="97px" HorizontalPadding="1px" />
<DynamicSelectedStyle ForeColor="White" />
<DynamicItemTemplate>
<div class="dinamicMenuItemTemplate">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Text") %>' EnableTheming="True"></asp:Label>
</div>
</DynamicItemTemplate>
<StaticMenuItemStyle ForeColor="White" CssClass="StaticMenuItemStyle" />
<StaticMenuStyle HorizontalPadding="10px" CssClass="StaticMenuStyle" />
<StaticSelectedStyle CssClass="staticMenuItemTemplateSelected" ForeColor="Red" />
<StaticItemTemplate>
<div class="staticMenuItemTemplate">
<div class="innerMenuElement">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Text") %>'></asp:Label></div>
</div>
</StaticItemTemplate>
</asp:Menu>
Now this is my css:
.staticMenuItemTemplate
{
background-position: left;
background-image: url('../../images/mainLayout/menuDefault.png');
background-repeat: no-repeat;
width: 100px;
text-align: center;
height: 25px;
position: relative;
top: 0px;
left: 0px;
}
.staticMenuItemTemplate:hover
{
background-image: url('../../images/mainLayout/menuHover.png');
background-repeat: no-repeat;
background-position: left;
font-weight: bold;
}
.staticMenuItemTemplateSelected
{
background-image: url('../../images/mainLayout/menuSelected.png') !important;
background-repeat: no-repeat !important;
background-position: left !important;
color: #FF00FF !important;
}
I want to display a different image when the menu item has been selected (menuSelected.png) but whilst the class staticMenuItemTemplate:hover seems to work and indeed the image changes, the class staticMenuItemTemplateSelected doesn't. Only the text gets pink as stated but the image won't change.
Thanks for your help.
I think the problem has to do with how the HTML renders for this control. In my tests, I end up with something like:
<td>
<a class="... staticMenuItemTemplateSelected ..." ...>
<div class="staticMenuItemTemplate">
<span>Menu text here</span>
</div>
</a>
</td>
So you can see that the <a> tag is getting the staticMenuItemTemplateSelected applied, but the inner <div> is getting the staticMenuItemTemplate class which ends up overriding the staticMenuItemTemplateSelected style since it is more specific.
If you change your declaration of .staticMenuItemTemplateSelected to
.staticMenuItemTemplateSelected .staticMenuItemTemplate
{
background-image: url('../../images/mainLayout/menuSelected.png') !important;
background-repeat: no-repeat !important;
background-position: left !important;
color: #FF00FF !important;
}
you will make that style more specific than the style for .staticMenuItemTemplate and it should work.
FireBug with FireFox is a great tool for investigating CSS weirdness issues.
I have a ModalPopupExtender set up on a page and working great. It's tied to a panel with some style attributes hardcoded into its tag. I'm trying to get all my styles out of my markup into CSS, but when I move these styles into a class, the popup fails to work. What's going on?
Styles in CSS:
.class1
{
border: solid 1px black;
display: none;
width: 700px;
height: 400px;
background-color: gray;
overflow: scroll;
}
.class2
{
background-color: White;
height: 90%;
width: 95%;
}
.backgroundClass
{
background-color: gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
Panel:
<asp:Panel ID="pnlModalContainer" runat="server" CssClass="class1">
<asp:Panel ID="pnlModalHandle" runat="server">
<table cellpadding="0" cellspacing="0" border="0" width="650px">
<tr>
<td>
Content Here |
<asp:Label ID="lblTitle" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<div style="padding-left: 25px;">
<table cellpadding="1" cellspacing="0" border="0" class="class2">
<tr valign="top">
<td>
<asp:UpdatePanel ID="udpPopups" runat="server">
<ContentTemplate>
...content here...
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr valign="bottom">
<td align="right" style="padding-bottom: 5px; padding-right: 5px;">
<asp:Button ID="btnModalOk" runat="server" Text="Ok" />
<asp:Button ID="btnModalCancel" runat="server" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</table>
</div>
</asp:Panel>
And the MPE:
<cc1:ModalPopupExtender ID="mpeAction" runat="server" PopupControlID="pnlModalContainer"
TargetControlID="fakeButton" BackgroundCssClass="backgroundClass" DropShadow="false"
PopupDragHandleControlID="pnlModalHandle" RepositionMode="RepositionOnWindowResizeAndScroll" />
This is in ASP .NET 2.0. Set up like this, I see the background show up, but the popup doesn't come up. But if I move the contents of class1 down to the markup as a style, it works great. The popup gets shown via Javascript emitted from VB code-behind, using ScriptManager.RegisterStartupScript().
UPDATE: I've seen this on other controls too; AJAX toolkit controls seem to like their layout styles inline, not in a stylesheet. Why is this?
It's possible that the specificity of the styles in the stylesheet is lower than the specificity of the inline styles. Try adding !important to the end of each property value. As in:
.class1
{
border: solid 1px black !important;
display: none !important;
width: 700px !important;
height: 400px !important;
background-color: gray !important;
overflow: scroll !important;
}
...
If that changes things, then you need a "more specific" selector than ".class1".
See: CSS Specificity
I have the following html which is display correctly in IE8. Below is the html and the css for grey_btn_75. Any idea why this would be happening?
<div style="float: left; width: 70px; margin-right: 25px; padding-top: 60px;
margin-left: 25px">
<asp:Button ID="btnAddAll" runat="server" Text="Add All"
OnClick="btnAddAll_Click"
CssClass="grey_btn_75" />
<div class="spacer"></div>
<asp:Button ID="btnAdd" runat="server" Text="Add"
OnClick="btnAdd_Click"
CssClass="grey_btn_75" />
<div class="spacer"></div>
<asp:Button ID="btnRemove" runat="server" Text="Remove"
OnClick="btnRemove_Click"
CssClass="grey_btn_75" />
<div class="spacer"></div>
<asp:Button ID="btnRemoveAll" runat="server" Text="Remove All"
CssClass="grey_btn_75"
OnClick="btnRemoveAll_Click" /><br />
</div>
CSS:
.grey_btn_75
{
background: url(../images/grey-75px.png);
background-repeat: no-repeat;
border-style: none;
font-family: Arial,Helvetica,Sans-Serif;
font-size: 12px;
font-weight: bold;
width: 75px;
height: 23px;
color: #000000;
cursor: pointer;
}
Things I have tried so far:
I removed the CssClass and the buttons still did not show up.
I modifed the CssClass and the buttons still did not show up.
I put other controls such as an asp:Label and and asp:ImageButton and they showed up fine.
I tried putting a new button and it did not show up.
Your div width is 70px, your button is 75px. You need to clean that up.
The problem is with the styles. Try commenting them out to see which one (or the combination) is responsible for the buttons to disappear.
Don't forget about the inline style of the top DIV as well.
This is a nice guide for button styles:
http://particletree.com/features/rediscovering-the-button-element/
People recommend
width:auto;
overflow:visible;
specifically for IE
I think it is the color value you have set in your CSS. I got the same problem previously and what I did was change the color value to something else.