Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] Javascript with ASP question

Started by grizzlebee May 2, 2006 at 8:46 AM 2 replies 600+ views
Original Post
grizzlebee
grizzlebee
I am using .NET and making a ASP.NET application I have created an ASP label named Label1. I want to change the text on Label1 using client side &#106avascript instead of the VB server side. Is this possible? With the VB server side I could just say me.Label1.text = "Hello". Thanks you.
Machaira
Machaira
I believe the following might do it:

var obj = document.getElementById('Label1');
obj.value = 'Some new text here';
Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development
Bob Janova
Bob Janova
In normal HTML you can just refer to objects by their name from within script, although it might have to be within the
tags.
markr
markr
Unfortunately you might think you can do that, but you're totally at the mercy of however
Last time I checked, in browsers which claim to be (or it thinks are) MSIE6 on Windows, it will use a span, otherwise it may use something else.

The exact rendering method of an ASPNET control is undocumented and should not be relied on not to change between versions. Moreover, it varies depending on the apparent target browser (NOT the *actual* target browser), the phase of the moon and such like.

Therefore, do not try to use client-script with a server control.

The safest way of doing it is putting it inside a normal
Otherwise you're at the mercy of the flawed-browser-detection and/or randomly-changing-between-versions implementation of the dodgy ASPNET controls.

Mark

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.