Page.RegisterStartupScript does not write javascript to page RRS feed

  • Question

  • User1820635600 posted
    I have an asp.net mobile application and need to use the RegisterStartupScript and/or the RegisterClientScriptBlock. However I can not get it to send the javascript to the page so that it can be executed. Below is a simple examle that does not work. The final version of the script will be more intense, but right now I would just like to see something simple work. Am I missing something? Or does this not work in Mobile Forms. This is the pageload sub in the code behind page. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Page.RegisterStartupScript("Test", "<script language='JavaScript'>alert('test worked!');</script>") End Sub Andy Steinmann andyast@gmail.com
    Thursday, February 24, 2005 5:30 PM

All replies

  • User-153924892 posted
    Andy, you should use a ScriptTemplate to write JavaScript to the device. You also have to define a filter supportsJavaScript in your Web.config. Devices you want to support must be configured on the machine level or the application level. <mobile:Form id="Form1" runat="server"> <DeviceSpecific> <Choice filter="supportsJavaScript"> <scriptTemplate> <script language='JavaScript'>alert('test worked!');</script> </ScriptTemplate> </Choice> </DeviceSpecific> </mobile:Form> Thomas
    Thursday, March 3, 2005 4:56 AM