cell alignment in Grid - c#

Hi I have a grid I'm trying to style. A skin was provided for me which contains:
#tblPageContent td
{
padding:0px;
margin:0px;
vertical-align:top;
text-align:left;
}
This is used to style other elements in the web application so I can't remove this.
The problem is this is styling my grid items to all be align left. I actually want them centered.
I tried to override this by adding a class to my grid and setting:
.myRadGridClass
{
text-align="center;
}
and
#myRadGrid td
{
text-align:center;
}
However this is not working right now.
Can someone please help me to get the grid cells centered without removing the skin css?

You only need to be more specific than the rule that's already defined.
I imagine that the HTML code generated looks like this :
<table id="tblPageContent">
<tr>
<td class="myRadGridClass">Content of your cell</td>
</tr>
</table>
If you go with the following css it should work :
#tblPageContent td.myRadGridClass
{
text-align:center;
}
If the HTML code doesn't look like this, post a snippet and we'll be able to help you out.

Related

CSS only works temporarily upon changing its value

I have a placeholder whose content (table and buttons) is generated dynamically based on the user choice. And I wanted to make the table vertically scrollable, and while doing so I have faced this unusual CSS behavior for me:
So I have the place holder as follow:
<div id="srollableTableDiv">
<asp:PlaceHolder ID = "roundingProblems_ph" runat="server" />
</div>
and I am applying the following CSS on the div:
#srollableTableDiv { height:500px; overflow:scroll; border:1px solid red; }
Now what happens is that when the table is generated, the CSS seems not to be working at all, but when I change a value in the CSS (for example make the border color to red or blue) the whole CSS would work in the browser without refreshing the page (I am using VS and chrome).. but once I refresh the page the CSS stops working again until I change CSS to another value!
Note: I am using bootstrap.
Could anyone explain what is the issue here?
Thank you very much.

Can't take text from a textarea asp.net

I have the following textarea declared inside an aspx page
Continut:<TextArea maxlength="4000" ID="Continut" name="Continut" runat="server" style="background-color: white; border : 1px solid #cccccc; width : 700px; height : 250px; resize : none;"></TextArea>
and I want to take the text from this textarea in C#. The code I use in C# looks like this
this.Request.Form["Continut"].Length < 1? "":this.Request.Form["Continut"]
Is there anything I do wrong or I just didn't fully understand how this works?
P.S. : I tried with another code and i get an eror that says : "System.Web.UI.HtmlControls.HtmlTextArea' does not contain a definition for 'Text'".
And the code is :
this.Continut.Text.Length < 1? "Document":this.Continut.Text
Ad1) Make sure that your control "Continut" is inside form.
Ad2) You should use Value property
http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltextarea.value(v=vs.110).aspx

Problems changing css properties of hyperlink in gridview

I have an asp.net gridview and have just added sorting to the columns. This has now obviously changed the column headers to links and they have changed to a blue colour but for some reason my modifications to change the colour of the links isn't working and they just wont pick-up the correct style.
Here is some CSS that I tried, I have tried it a few other ways too but wanted to test it using the most basic setup:
a:link {
color:white;
}
a:visited {
color:white;
}
use !important with Sachin's answer
a{
color:white !important;
}
Try this
div #something .gridview td a{
Color: red! important;
}
Try to set style more specific to your anchor tag.

Creating a CSS class programmatically ASP.Net

I have a DIV that I would like to modify the CSS for programmatically in VB.Net/C#.
I know that, for example, I could add style attributes simply by
divMyDiv.Style.add("color","#ff0000")
but I want to add a new CSS class, together with its attributes to the DIV. So in an ideal world I would like to write something like
divMyDiv.Style.add(".smallRedText", "{font-size:10px; color:#ff0000}")
Is this even possible ? Am I missing the bigger picture ?
All help gratefully received :-)
What about:
divMyDiv.Attributes.Add("class", "new-class")
I suggest that you define the variations in css ahead of time that you know you'll need. Then, you can manipulate the class attribute of whatever control you need to change on the fly.
For example, you could define:
.smallRedText { font-size: 10px; color: #ff0000 }
.smallBlueText { font-size: 10px; color: #0000ff }
Then when comes time to select dynamically:
divMyDiv.Attributes.Add("class", whateverClassWeNeed);

How to add a CssClass to the current displayed month in ASP.Net Calendar webcontrol

I am currently working on implementing an ASP.Net calendar (system.web.ui.webcontrols.calendar) into a design which requires me to add a class to the displayed month in the title. To be specific, the rendered code today is:
<tr>
<td>[Previous navigation link goes here]</td>
<td>August</td>
<td>[Next navigation link goes here]</td>
</tr>
What I would like to have is:
<tr>
<td>[Previous navigation link goes here]</td>
<td class="CustomCssClass">August</td>
<td>[Next navigation link goes here]</td>
</tr>
Is this possible? I have not found any property which solves my problem nor have I had any success in fetching the actual HTML server control.
Thanks in advance,
David.
Assuming that you are talking about the ASPNet AjaxToolKit Calendar Control:
The relevant class for the header is "ajax__calendar_header". You override this class in your css.
.ajax__calendar_header { background-color: yellow !important; }
Edit: after op comments:
Using the server control, there is a property called TitleStyle. You can specify your formatting here. Alternatively, you can use the property TitleStyle-CssClass to apply a css class to the header.
<asp:Calendar ID="cal" runat="server" TitleStyle-CssClass="cssclass"></asp:Calendar>
Hope that helps.

Categories

Resources