?
Solved

Change a div's style in code behind

Posted on 2011-05-12
6
Medium Priority
?
649 Views
Last Modified: 2012-05-11
I have a multiview and some linkbuttons. When the linkbutton is clicked, i display the correct multiview view...

I want to change the CSS property in the code behind. Not sure how I can do this. I made the div server side by adding runat...

My coworker says "since you have an index of steps within your MultiView, you can use that count to iterate over your HTML steps applying the proper classname"...not sure what he means...
<div id="stepNumber1" runat="server" class="stepNumber completed"><asp:LinkButton  OnClick="onClick_Step1" runat="server" ID="step1"><strong>Step 1</strong><br />
             Personal Info </asp:LinkButton></div>



 protected void onClick_Step1(object sender, EventArgs e)
    {
        mvApplication.ActiveViewIndex = 0;
        //change that class="stepNumber Completed" to class ="stepNumber NotComplete". I think i need to use Style
        
    }

Open in new window

0
Comment
Question by:Camillia
6 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 35746800
try this:
http://www.tamilcodes.com/document.aspx?content=Snippets&id=43
quoted for You:

CodeBehind:




 
 .aspx file


 <form id="form1" runat="server">
  <div>
   
  <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
   
  </div>
  </form>


protected void Page_Load(object sender, EventArgs e)
  { 
    foreach (string x in Request.ServerVariables)
     {
        Label1.Text += x.ToString() + " : ";
        Label1.Text += Request.ServerVariables[x].ToString() + "<br/>";
     }
  }

Open in new window

0
 
LVL 7

Author Comment

by:Camillia
ID: 35746836
but still, how do I change that div's class to another class? i think i need to do something with
divId.style.something??
0
 
LVL 7

Author Comment

by:Camillia
ID: 35746877
Something like this?? stepNumber1.Attributes.CssStyle.Add(?)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Accepted Solution

by:
Rick earned 2000 total points
ID: 35746983
stepNumber1.Attributes["class"] = "YourClassHere";
0
 
LVL 35

Expert Comment

by:YZlat
ID: 35747030
stepNumber.CssClass = MY_CLASS
0
 
LVL 35

Expert Comment

by:YZlat
ID: 35747051
stepNumber1.CssClass = "New clas name here";
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question