How to include js file through .cs????
-
Hi friends, I am using .NET 2008 version. I want to include my js files, but not by standard way like '' but from .cs file. The problem is in above example, "companyname" can change and its comming from another xml file, which i am reading in .cs, so i have to give source of js file in cs.:confused: I have found 1 function "RegisterClientScriptInclude" in C#, but its not working. :( Please any one can help me to perform my task or please show me how to use "RegisterClientScriptInclude" function. Thanks for any help in advance. Happy Coding.:rose: Anand Desai Developer Atharva Infotech
-
Hi friends, I am using .NET 2008 version. I want to include my js files, but not by standard way like '' but from .cs file. The problem is in above example, "companyname" can change and its comming from another xml file, which i am reading in .cs, so i have to give source of js file in cs.:confused: I have found 1 function "RegisterClientScriptInclude" in C#, but its not working. :( Please any one can help me to perform my task or please show me how to use "RegisterClientScriptInclude" function. Thanks for any help in advance. Happy Coding.:rose: Anand Desai Developer Atharva Infotech
Hi Anand, try this line of code where u r currently writing the RegisterClientScriptInclude function,replace with this ClientScript.RegisterClientScriptBlock(typeof([ur .cs classname here]),"one"," "); company name is a variable that will include the name from ur xml file hope it helps Rajeesh K
-
Hi friends, I am using .NET 2008 version. I want to include my js files, but not by standard way like '' but from .cs file. The problem is in above example, "companyname" can change and its comming from another xml file, which i am reading in .cs, so i have to give source of js file in cs.:confused: I have found 1 function "RegisterClientScriptInclude" in C#, but its not working. :( Please any one can help me to perform my task or please show me how to use "RegisterClientScriptInclude" function. Thanks for any help in advance. Happy Coding.:rose: Anand Desai Developer Atharva Infotech
Dont bother for this question friends, i have solved it myself. all i did is:
string jspath = "scripts/" + this.company + "/main.js";
String csname = "PageLoadScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptInclude(cstype, csname, ResolveClientUrl("~/" + jspath));Thanks friends and use this if any one is faciong this problem.
Anand Desai Developer Atharva Infotech
-
Hi Anand, try this line of code where u r currently writing the RegisterClientScriptInclude function,replace with this ClientScript.RegisterClientScriptBlock(typeof([ur .cs classname here]),"one"," "); company name is a variable that will include the name from ur xml file hope it helps Rajeesh K
Thanks Rajeesh, It is another good and shorter way, let me try by urs way, it'll save my time. Thanks for help.
Anand Desai Developer Atharva Infotech
-
Dont bother for this question friends, i have solved it myself. all i did is:
string jspath = "scripts/" + this.company + "/main.js";
String csname = "PageLoadScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptInclude(cstype, csname, ResolveClientUrl("~/" + jspath));Thanks friends and use this if any one is faciong this problem.
Anand Desai Developer Atharva Infotech
just rember one more thing, when you have AJAX on that page you have to use ScriptManager, insted of ClientScriptManager
cheers, Abhijit
-
just rember one more thing, when you have AJAX on that page you have to use ScriptManager, insted of ClientScriptManager
cheers, Abhijit
Thanks buddy
Anand Desai Developer Atharva Infotech
-
Hi Anand, try this line of code where u r currently writing the RegisterClientScriptInclude function,replace with this ClientScript.RegisterClientScriptBlock(typeof([ur .cs classname here]),"one"," "); company name is a variable that will include the name from ur xml file hope it helps Rajeesh K
Thanks, your code helped me to include css file also, i was not able to include css file through cs by my code. All i did is:
protected void Page_Init(object sender, EventArgs e)
{
Servicepath = "xmls/saltours/general/services.xml";
string jspath = "scripts/companyname/main.js";
String csname = "PageLoadScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptInclude(cstype, csname, ResolveClientUrl("~/" + jspath));
ClientScript.RegisterClientScriptBlock(typeof(PackageList), "one", "");
ClientScript.RegisterClientScriptBlock(typeof(PackageList), "two", "");
}and I got what was required.... Thanks,
Anand Desai Developer Atharva Infotech