Sunday, 20 January 2013 13:55

how to register script file from asp.net code behind file

Written by 
Rate this item
(0 votes)

you may need to register javascript file/css file from code
behind when needed.for this follow the codes below -

StringBuilder sb = new StringBuilder();

sb.AppendFormat("<link rel=\"stylesheet\" href=\"{0}/jquery-ui/jquery-ui.css \"
type=\"text/css\" />{1}", this.TemplateSourceDirectory, "\r\n");

sb.AppendFormat("<script type=\"text/javascript\"
src=\"{0}/jquery-ui/jquery-ui.min.js\"></script>{1}",
this.TemplateSourceDirectory, "\r\n");

Page.ClientScript.RegisterStartupScript(this.GetType(),
"Cp_Detail_Script", sb.ToString());


here i registered jquery-ui.min.js and jquery-ui.css
files in jquery-ui folder in my dotnetnuke modules directory.
there are no problems if you register in normal asp.net
website/app.

Read 3993 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments