Let .NET Mobile Web Application support Javascripts

2008-04-30


Is JavaScript supported in Mobile web application ? If yes, How ?

Just give some samples:

**in web.config **

< system.web>

< deviceFilters>

< filter name="supportsJavaScript" compare="Javascript" argument="true"/>

</ deviceFilters>

</system.web>

** in aspx**

<mobile:Form ID="Form1" Runat="server">

<mobile:TextBox ID="TextBox1" Runat="server">

</mobile:TextBox>

<mobile:Command ID="Command1" Runat="server" OnClick="Command1_Click">Command</mobile:Command>

<mobile:Panel ID="Panel1" Runat="server">

<mobile:DeviceSpecific ID="DeviceSpecific1" Runat="server">

<Choice Filter="supportsJavaScript" Xmlns="http://schemas.microsoft.com/mobile/html32template">

<ContentTemplate>

<script language="javascript">

var control;

control = document.Form1.TextBox1;

control.focus();

</script>

</ContentTemplate>

</Choice>

</mobile:DeviceSpecific>

</mobile:Panel>

</mobile:Form> check if the device supports javascript?

if (Page.Request.Browser.JavaScript == true)

Response.Redirect( "~/SupportsJava.aspx");

else

Response.Redirect("~/NotSupportsJava.aspx");

( from : http://forums.asp.net/thread/1581990.aspx )