ASP.NET - <DIV> tag  ASP.NET - <DIV> tag

Asked By Jeff J
18-Feb-09 03:39 PM

I have a div tag on my asp.net page. It encompasses a couple of server side controls. But this div tag does not have the runat=server attribute attached to it. i.e it is a client side control.

I am trying to disable most of the controls based on the user who logs in. all of the controls that get disabled are under the div tag. A css stylesheet style is also attached to the div tag. I am wanting to apply a different style on runtime. is it possible to apply a different style to the div tag based on runtime even if it is not a server side control ?

The problem is that once I attach the runat=server attribute then the css styling get's skewed.

Also what is the best way to apply styling to a client side control on runtime ?

 

<DIV> Tag  <DIV> Tag

18-Feb-09 06:56 PM

Have you looked at the JQuery Library?  This is a most useful tool and you can change CSS Classes using JQuery.  Check out this link:  http://jquery.com/

Aloha,

Kevin

  Vasanthakumar D replied to Jeff J
19-Feb-09 12:41 AM

Hi,

you can change the css class name from code behind for client controls like this...

in page load or any event try this

string strScr = "";

if(condition == true)

{

       strScr = "document.getElementById('Div ID').className='Style1';";

    }

else

{

  strScr = "document.getElementById('Div ID').className='Style2';";

}

Page.ClientScript.RegisterStartupScript(this.GetType(), "cssclas", strScr, true);

Thanks  Thanks

19-Feb-09 12:05 PM
this is probably a good technique to invoke some javscript. Although I am trying to avoid javascript... but it can be worth a try.
  Vasanthakumar D replied to Jeff J
19-Feb-09 12:18 PM

hi,

Is there any other methods available for this?

Create New Account
help
is the code. . .but please tell me why slide show is not running. . . . . . ?? on ASPX Page: protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["Id"] ! = null) { uint Id = Convert.ToUInt16(Request.QueryString["Id"].ToString()); FillControls(Id); GetImages(Id); GetImage(Id); } ScriptManager.RegisterStartupScript(this, this.GetType(), "myScript1", "slideshow_automatic();", true); } public void GetImage(uint id) { Test ts = new Test WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] / / To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class Test : System.Web.Services.WebService { public Test () { / / Uncomment the following line if using designed components WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] / / To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class Test : System.Web.Services.WebService { public Test () { / / Uncomment the following line if using designed components
application or web application to consume this service? It is True / False? FALSE How many classes can a single.NET DLL contain? Answer1: As many Answer2: One or more What are cannot be used with indexers, destructors, or types. In C#, the static keyword indicates a class variable. In VB, the equivalent keyword is Shared. Its scoped to the class in which it occurs. Example a. Static int var / / in c#.net b. static void in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging enable the trace
ASP.NET AJAX Maintain Scroll Position from a Partial Page Update How to Maintain Scroll Position from a Partial Page Update - Using Ajax. On and off for a while now I have worked with the part of an update panel after an update has occurred. Thats where the client-script libraries that MS distributes comes into play. With-in this library there are two big players for my scenario. . . 1. Sys.WebForms.PageRequestManager beginRequest Event - - 2 WebForms.PageRequestManager endRequest Event , and of course the ScriptManager that has to be on every page that a UpdatePanel is on (Or if you are using a masterpage you may use visibility = 'hidden' ; } < / script > - -- -- -- -- -- -- -- -- -- -- -- -- - If you are thinking to yourself, "WOW that looks alot like the Page Model in .net." Well, my dear Watson you would be correct. I am not going
faqs on masterpages Hi all, can anybody tell me the FAQs on Masterpages in asp.net. Thanks alot var Hi What are Master Pages in ASP.NET? or What is a Master Page? ASP.NET master pages allow you to create a consistent layout for the pages in your application
a plug-in or without compromising on the user’s ability to interact with the page. This is possible due to an object found in browsers called the XMLHttpRequest object. What is ASP.NET AJAX? ‘ASP.NET AJAX’ is a terminology coined by Microsoft for ‘their’ implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries. Which is the current version of ASP.NET AJAX Control Toolkit? As of this writing