Skip to content

How to get the property value of any of the control in runti

Dilip Solanki

Dilip Solanki

Asked Apr 8, 2013, 2:40 AM EDT1 answer
Share
LinkedInX
Hello Frndz...

I have 2
, one is created in design time and one is created in runtime. Now i want to get the property value of these
, which is set at the time of creation. E.G.

Like for div 1:



Code
for div 2:


HtmlGenericControl div1=new HtmlGenericControl();
div1.ID="hello";
div1.style.add("left","300px");



After creating my
like this, i would like to get the value of left property of both
in runtime using c#.


How can i get it...?

Thanks..

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Vishal Gilbile
    0
    Hello Friend,
                      you can only access server control in your code behind. Therefore you will have to set the attribute runat="Server" on both the div and also provide a unique id through which you can access those div's.

    And you can access it like the following

    Code
    var style = first.Attributes["style"];
    
    
    Hope that solves your problem,
    
    With Regards,
    Vishal Gilbile
    0