Last post Nov 15, 2006 06:01 AM by thomasvsundert
Nov 14, 2006 10:57 AM|thomasvsundert|LINK
Hi, I'm making a mobile web page that uses client side scripting (using a <mobile:DeviceSpecific> control) and my web page looks something like this:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="mob.aspx.cs" Inherits="mob" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<mobile:Form ID="form1" Runat="server" Wrapping="NoWrap">
<mobile:Label ID="head" Runat="server"></mobile:Label><mobile:Label ID="content" Runat="server"></mobile:Label></mobile:Form></body></html>
Now i'm trying to reference to the "head"-element on this page from myScript using document.getElementById("head"), but this doesn't work (error: document.getElementById("head") has no properties) Is there any way I can reference to my mobile controls from
my client-side code?
Nov 14, 2006 11:35 AM|Pealy|LINK
Hi. You don't say what device you're targetting but you're generally flogging a dead horse trying to use getElementById.
I have found that the ability to reference controls is very frustrating and sometimes depends what kind of container you use (table/panel etc).
I have a command button inside a table on a form. it's defined with the following:
<INPUT id="cmdCTRLStop" style="FONT-SIZE: 8pt; WIDTH: 24px; HEIGHT: 21px" onclick="StopClick(0);"
type="button" value="O" name="cmdCTRLStop" >
The following part of the StopClick script allows me to change the text on it:
pic1 = document.Form1.cmdCTRLStop;
Nov 14, 2006 11:54 AM|thomasvsundert|LINK
The problem is that when I use an asp:Label control, this creates plain text at the client. What I would really like is that it creates an element that has an Id, so I can reference it (or a way to reference the plain code created, document.Form1.controlName
doesn't work either)
Nov 15, 2006 03:41 AM|Pealy|LINK
< INPUT id="new_lblStage0" title="new_lblStage0" style="WIDTH: 274px; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; HEIGHT: 18px; BORDER-BOTTOM-STYLE: none"
readOnly type="text" size="40" name="new_lblStage0" >
This way you can use code like this:
Label1 = document.Form1.new_lblStage0;
Label1.value ="Checking DB & Initialising Service";
instead of having to do a full postback.
Nov 15, 2006 06:01 AM|thomasvsundert|LINK
I'm using mobile:Label for the simple reason that this will make sure that my site can be viewed on most mobile devices. By using <input>, some devices won't be able to view this control.
For this reason I can only use ASP.NET mobile controls (otherwise my problem wouldn't be a problem)