webressurs
asked on
Execute javacript from code behind
Hi!
I have an asp.net page that is called from an externat system (credit card company). When the asp.net file is requested I need to make a JavaScript Call from the asp.net code behind file. The problem is that the JavaScript never runs.
Asp.net code front:
Asp.net code behind:
How can I Call this JavaScript for code behind?
I have an asp.net page that is called from an externat system (credit card company). When the asp.net file is requested I need to make a JavaScript Call from the asp.net code behind file. The problem is that the JavaScript never runs.
Asp.net code front:
<asp:PlaceHolder runat="server" ID="plhAnalytics" />
Asp.net code behind:
protected void Page_Load(object sender, EventArgs e)
{
if ([A LOT OF STUFF])
{
TrackAnalytics();
}
}
protected void TrackAnalytics()
{
PlaceHolder plhAnalytics = this.plhAnalytics;
HtmlGenericControl objScript = new HtmlGenericControl("script");
objScript.Attributes.Add("type", "text/javascript");
System.Text.StringBuilder strScript = new System.Text.StringBuilder();
strScript.Append("analytics.identify('1234567890', {\n");
strScript.Append("plan: 'Paid'\n");
strScript.Append("});\n");
strScript.Append("analytics.track('Payment Created', {\n");
strScript.Append("category: '" + type + "'\n");
strScript.Append("});\n");
objScript.InnerHtml = strScript.ToString();
plhAnalytics.Controls.Add(objScript);
}
How can I Call this JavaScript for code behind?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER