Hot to add CSS style to your Controls at runtime?

27 09 2008

You can add css style to any of asp.net control dynamically as given below

btnViewed.Style["font-weight"] = “bold”;

Hopefully it will help.





Finding control In Ajax Tab container

27 09 2008

Suppose you have a repeater control inside ajax tab container and you want to bind data with that repeater. If on your page you try to directly bind data with it, it will generate error and say that “repeater is not found”.

You have to first find the repeater and then you can do all the things with it as you do in normal .

Control myControl = TabContainer1.Tabs[0].FindControl(“RepeaterName”);

Repeater MyRepeater = (Repeater)myControl;

or simply in single step

Repeater MyRepeater =(Repeater)TabContainer1.Tabs[0].FindControl(“RepeaterName“);

Now you can bind data with it or do any operation with this repeater.

Hopefully it will help, if find helpful please leave a comment





How to Programmatically add JavaScript File to Asp.Net page?

27 09 2008

If you do not want to add your JavaScript files declaratively via HTML to your ASP.Net page, you can do it in code, and here is how:

Just add this code to the Page_Init event handler on your page:


protected void Page_Init(object sender, EventArgs e)

{

HtmlGenericControl js = new HtmlGenericControl(“script”);

js.Attributes["type"] = “text/javascript”;

js.Attributes["src"] = “jscript/formfunctions.js”;

Page.Header.Controls.Add(js);

}


And thats all there is to it http://www.aspdotnetfaq.com/fckeditor/editor/images/smiley/msn/wink_smile.gif.