Friday 28 September 2012

ASP.NET : Get Div Style info from CodeBehind

I've answered :  http://forums.asp.net/t/1846358.aspx
Today I'm going to explain how can we get the Div or any Style Info of HTML Control from CodeBehind.
Suppose we have Div (with runat="server" attribute, means accessible from CodeBehind).



<div runat="server" id="velicina" style="max-width:500px;"></div>

First Add This NameSpace:
using System.Web.UI.HtmlControls;
Then Write Code:
HtmlControl YourDiv = (HtmlControl)Page.FindControl("velicina");
Response.Write("<b>Its the Width of your Div: velicina = " + Convert.ToString(YourDiv.Style["max-width"]) + "</b>");
OUTPUT:
Its the Width of your Div: velicina = 500px
Hope my this tutorial will be helpful.

2 comments:

genga g said...
This comment has been removed by the author.
rohini said...

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
iWatch service center chennai | apple ipad service center in chennai | apple iphone service center in chennai | Apple laptop service center in chennai

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More