I have a javascript link which I need to appear in a table on my aspx page. Hard coding it as a literal isn’t working right. Consultation with the script’s provider suggests I shouldn’t hard-code it, but should embed it using ScriptManager. How do I get the link as javascript into the appropriate place in my page (it goes in a table)? I have this code to register the script:
string myScript = "http://forms.aweber.com/form/85/1556724385.js";
ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", myScript);
I want this link to appear in this table cell:
<asp:TableRow ID="TableRow3" runat="server">
<asp:TableCell ID="TableCell4" runat="server" HorizontalAlign="Center">
</asp:TableCell>
</asp:TableRow>
Not clear on how to do this… insert into some control inside the cell, such as a Panel? And I am unclear on how to “emit” the script.
Edited to add:
After communicating with the vendor, it is clear that trying to do what I am trying to do in an ASP.NET page will not work — at least with the current version of the product. So I’ve accepted @cccason’s answer, since it comes closest to what the answer would be if the situation were otherwise.
So, I would suggest just dropping it in there instead of using RegisterClientScriptBlock if you need it anywhere EXCEPT the start of the form tag.
The RegisterClientScriptBlock method places the JavaScript directly after the opening element in the page.
So I would do something like this:
So, whats happening in the script is that it writes some DOM elements out to your page. Since you are using webforms, this all sits inside of a tag. The stuff they are writing to your page is another . So you’ll end up with a form in a form. Then, when you submit the information, it is supposed to postback to http://www.aweber.com/scripts/addlead.pl.
You should check the request that is being sent and see what its trying to do. You can use firefoxes firebug, fiddler or chrome’s tools (f12).