Problem calling Anchors

L

Lars Netzel

I have manually written an achor in the HTML mode like this:

<a name="expenses"></a>

Then at a button_click() I have this code in the code behind:
Page.Controls.Add(New LiteralControl("<script language = ""javascript"">"))

Page.Controls.Add(New LiteralControl("document.location.hash=""expenses"""))

Page.Controls.Add(New LiteralControl("</script>"))

----------------------------------------------------

This normaly works fine but not on this page cause I have added some own
javascript with errortexts that comes from <%... %> links... so I get the
following error message when clicking the button.

The Controls collection cannot be modified because the control contains code
blocks (i.e. <% ... %>).
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot
be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

Line 680: btnAddnewLodging.Enabled = False
Line 681:
Line 682: Page.Controls.Add(New LiteralControl("<script language =
""javascript"">"))
Line 683: Page.Controls.Add(New
LiteralControl("document.location.hash=""lodging"""))
Line 684: Page.Controls.Add(New LiteralControl("</script>"))


------------------

This of course is bad and I need to find another way of adding the
"#expenses" to the URL.. and why is the javascript I wrote considered to be
part of the control i'm adding?

Please help

Best Regards/

Lars Neztel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top