1
Answer

Setting Up CSS on any DIV using C#

Photo of Dilip Solanki

Dilip Solanki

12y
1.4k
1
Good Afternoon Friends..
I want to apply stylesheet dynamically on <div>, which i have created in design time.
I have only 1 .aspx webpage, which i have created in visual studio 2010.
My default.aspx page code as below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
 <title></title>
 </head>
 <body> 
 <form id="form1" runat="server">
 <div id="testing"> 
</div>
 </form> 
</body> 
</html>
 
Now i want to apply stylesheet on above div with  "testing" id.

I want to apply these stylesheet properties with div:
background-color
border
width
height
font

I have did this task by using javascript but now i want to do this using c#.
How can i do it, plz help me...?

Answers (1)

0
Photo of frostyraver
NA 20 0 15y
I know in c# you can do something like this

// If there is selected items do this
if (lisbox.items.selected != null)
{
// Code for your program here if the listbox is selected
}
// If there are no items selected then display this
else
{
 // Error display code here
}

You could maybe set up an error checker that way?
0
Photo of sara khatib
NA 3 0 16y
thank you for replaying my letter but: 1-customer.id is an interger value declare in my customer class 2-rd[0] only have single value from the stored procedure (select min(id) from customer ) the problem is when there is no data in the table it return Null i try to put all my code in TRY{} and CATCH{} but i doesnt work ,if you have ny idea to this setuation i need it very much in my project thanks again
0
Photo of frostyraver
NA 20 0 16y
I might be of some help....i'm still learning this feel free to correct me :D.

customer.id <= is this customer id an int?

=convert.toint32(rd[0].tostring) <= your trying to convert an array of customer ids to an int?

I'm not sure elaborate on this subject. If your seeing this message it's because you have a string value somewhere, you might need more converts or something.