When I try to register this script in my trace it says it is not registered Even though I exclaim its registration here:
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "DrillThrough report " + (int) dr["ReportID"] + " script", vbs_script);
The scripts file name is DrillThrough6-0.Function.BT.SS2005.ReportID42193.vbs
What could be going wrong. Plus if I run Internet explorer using developer tools(maybe just a coincidence, but it constantly happens only with developer tools on) it registers fine. And runs as its suppose to otherwise it doesn't run at all.
Code for Context:
SqlDataReader dr = PivotTableDB.GetReport(drillThroughReportID);
Trace.Warn("Attempting to Read... ");
if (dr.Read()) {
Trace.Warn("Reading... ");
Page.ClientScript.RegisterHiddenField("txt_DetailReportCubeName", (string) dr["CubeName"]);
string path = (string) this.MapPath("~/DesktopModules/PivotTableNav/DrillThroughReportScripts/");
string name = (string) dr["DisplayName_en"] + ".ReportID" + (int) dr["ReportID"] + ".vbs";
string vbs_script = "";
if (File.Exists(path + name)) {
StreamReader sr = new StreamReader(path + name,System.Text.Encoding.GetEncoding("iso-8859-1"));
vbs_script = sr.ReadToEnd();
vbs_script = vbs_script.Replace("Spreadsheet1","document.Form1.Spreadsheet1");
vbs_script = vbs_script.Replace("for=document.Form1.Spreadsheet1","for=Spreadsheet1");
sr.Close();
}
if (vbs_script != null) {
Trace.Warn("vbscript", vbs_script);
Trace.Warn("vbscript-path", (path + name));
Trace.Warn("vbscriptExist", "File exist: " + File.Exists(path + name) + " BlockRegistered already: " + Page.ClientScript.IsClientScriptBlockRegistered("DrillThrough report " + (int)dr["ReportID"] + " script"));
if (! Page.ClientScript.IsClientScriptBlockRegistered("DrillThrough report " + (int) dr["ReportID"] + " script"))
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "DrillThrough report " + (int) dr["ReportID"] + " script", vbs_script);
}
Trace.Warn("Was vbscript Registered: " + Page.ClientScript.IsClientScriptBlockRegistered("DrillThrough report " + (int)dr["ReportID"] + " script"));
Title.Text = LanguageUtils.ChooseOnLanguage(dr["DisplayName_en"].ToString(), dr["DisplayName_fr"].ToString());
}
else { Trace.Warn("Did not read the report since no data no rows: "); }
dr.Close();
To get this to work i changed RegisterClientScriptBlock to RegisterStartupScript. And now the register is successful , obivious change isClientScriptBlockRegistered to the IsStartupScriptRegistered.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.