1

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.

2 Answers 2

2

RegisterClientScriptBlock method just adds specified javascript block(literal) to the page. To include any internal or external javascript file you should to use RegisterClientScriptInclude method.

Sign up to request clarification or add additional context in comments.

Comments

1

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:

<asp:TableRow ID="TableRow3" runat="server">
   <asp:TableCell ID="TableCell4" runat="server" HorizontalAlign="Center">
       <script type="text/javascript" src="http://forms.aweber.com/form/85/1556724385.js"></script>
   </asp:TableCell>
</asp:TableRow>

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).

2 Comments

Sigh. Yes, I tried that. It presents the form on the page but it doesn't behave the way it is supposed to. If I put the script on a plain HTML page it works fine. I am afraid I am going to have to get some direction from the vendor. Thanks for trying, though!
What it is supposed to do is call back to the vendor's API in the cloud somewhere, register the information, send me an email notification, and then transfer to another page on my site confirming to the user that registration occurred. It doesn't do this on the ASP.NET page, it just redisplays the page. I have confirmed that the script works fine on a straight HTML page. Which is what I am probably going to do unless and until I find a way to host it on ASPX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.