Hi...
I have a .js file...
Name - myfile.js in the App_Themes/JS folder
How do I call this file from code - behind in c# asp.net ??
I need this file once the GridView is loaded...
Scenariao -
I have a button - "Load" on aspx page.
ON btn_click event, I have loaded the gridview with datatable.
After the gridview is loaded, I need to call this file..
How do I do that ??
I do not want to call it is aspx page.
Loading

Vincent Maverick DuranoRank #238 · 10.3K reputationPosted May 4, 2015, 6:09 AM EDT
Riddhi ValechaRank #794 · 2.9K reputationPosted May 4, 2015, 11:45 PM EDT
The purpose is not served dear....
In the file... the following lines are there -
var Headers[] = ,
for(var i = 0; i < headers.length; i++)
for (var i = 0, row; row = tablebody.rows[i]; i++)
------------
It is for responsive gird view....
When I click the button, and restore the Internet Explorer , then column names must appear..
I am only getting values of rows...and not column names....
Manoj BhoirRank #599 · 4K reputationPosted May 5, 2015, 2:12 AM EDT
Add your Javascript file reference on your page.
You can use this code on your Button Click event :
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"");
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JavaScriptCall", sb.ToString(), false);
Riddhi ValechaRank #794 · 2.9K reputationPosted May 6, 2015, 1:50 AM EDT
I did all these methods... None worked out !
Riddhi ValechaRank #794 · 2.9K reputationPosted May 12, 2015, 11:28 PM EDT
My .js file code is -
var headertext = [],
headers = document.querySelectorAll(".mytable th"),
tablerows = document.querySelectorAll(".mytable th"),
tablebody = document.querySelector(".mytable tbody");
for(var i = 0; i < headers.length; i++) {
var current = headers[i];
headertext.push(current.textContent.replace(/\r?\n|\r/, ""));
}
for (var i = 0, row; row = tablebody.rows[i]; i++) {
for (var j = 0, col; col = row.cells[j]; j++) {
col.setAttribute("data-th", headertext[j]);
}
}
------
This gives error on page_load if I call this on aspx page.
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted May 12, 2015, 11:34 PM EDT
Riddhi ValechaRank #794 · 2.9K reputationPosted May 15, 2015, 1:08 AM EDT
This code also didnt work...
I need column-heading in the side... But they are on the top...
This is when the "Restore" button of Internet Explorer is clicked...