473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to implement a "value" property for Web User Controls?

Hi--
Sample. When i write something like:
<input type="button" name="btnSend" value="Send"
onclick="callSo meTask(getEleme ntById('myContr ol').value );return false;
/>

I can run some cliente code if "myControl" is an Asp Textbox;
getElementById( 'myControl').va lue get current Text of Textbox

If i write a Web User Control, i dont know how to implemente the property
"value", value runs for the cliente not in server.

Thanks,
<Harvey Triana />
Apr 23 '07 #1
3 1717
I'm not certain I understand what you're asking, but I'll take a guess. You
need the client ID an html element that asp.net generates, correct? There
is a .ClientID property that will expose that. So, you have to pull that
client ID from your code behind and inject it into your client-side code in
someway. You can build strings in your codebehind containing javascript
functions, but I personally find this to be a PITA. So, I use a Literal
that's hidden and put my client-side code in there, alter it as needed, and
then register the text of it. This makes for a better Visual Studio
experience. Here's a sample:


codebehind:
protected void Page_Load(objec t sender, EventArgs e)
{
litClientScript .Text = litClientScript .Text.Replace(" %someTextBox%",
someTextBox.Cli entID);
Page.RegisterCl ientScriptBlock ("JS", litClientScript .Text);
}
..aspx:

<asp:textbox id="someTextBox " runat="server" text="here's some text" />
<input type="button" onclick="giveIt ();" value="Click me" />

<asp:literal id="litClientSc ript" runat="server" visible="false" >
<script type="text/javascript">
function giveIt() {
alert(document. getElementById( '%someTextBox%' ).value);
}
</script>
</asp:literal>
Ray at work
"Harvey Triana" <ha**********@h otmail.comwrote in message
news:Oz******** *****@TK2MSFTNG P03.phx.gbl...
Hi--
Sample. When i write something like:
<input type="button" name="btnSend" value="Send"
onclick="callSo meTask(getEleme ntById('myContr ol').value );return false;
/>

I can run some cliente code if "myControl" is an Asp Textbox;
getElementById( 'myControl').va lue get current Text of Textbox

If i write a Web User Control, i dont know how to implemente the property
"value", value runs for the cliente not in server.

Thanks,
<Harvey Triana />
Apr 23 '07 #2
this will depend on what dom elements your user control renders.

-- bruce (sqlwork.com)

Harvey Triana wrote:
Hi--
Sample. When i write something like:
<input type="button" name="btnSend" value="Send"
onclick="callSo meTask(getEleme ntById('myContr ol').value );return false;
/>

I can run some cliente code if "myControl" is an Asp Textbox;
getElementById( 'myControl').va lue get current Text of Textbox

If i write a Web User Control, i dont know how to implemente the property
"value", value runs for the cliente not in server.

Thanks,
<Harvey Triana />

Apr 23 '07 #3
this will depend on what dom elements your user control renders.
A sample, please...

<Harvey Triana />

"bruce barker" <no****@nospam. comescribió en el mensaje
news:OM******** ******@TK2MSFTN GP05.phx.gbl...
this will depend on what dom elements your user control renders.

-- bruce (sqlwork.com)

Harvey Triana wrote:
>Hi--
Sample. When i write something like:
<input type="button" name="btnSend" value="Send"
onclick="callSo meTask(getEleme ntById('myContr ol').value );return
false; />

I can run some cliente code if "myControl" is an Asp Textbox;
getElementById ('myControl').v alue get current Text of Textbox

If i write a Web User Control, i dont know how to implemente the property
"value", value runs for the cliente not in server.

Thanks,
<Harvey Triana />

Apr 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6494
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key" labelProperty="value"/> In this case "key" is what I mean by "ID", and "value" is what I mean by "Value" -- the "Value" is shown to the user, but the "ID" is what I...
7
2938
by: Don | last post by:
Via JavaScript within the client page containing the checkbox, I'm trying to capture the value of a checkbox to make a cookie out of it. But, all I get is the defined "ON" value, even when it is unchecked. I'm using the following construct: document.cookie = "cpceRememberLoginCookie="+document.getPage1.rememberLogin.value+"; expires=Thr,...
2
3922
by: VB Programmer | last post by:
I created a VB6 user control with a ActiveX Knob on it. Here's the simple code: Public Property Get Value() As Integer Value = CWKnob.Value End Property Public Property Let Value(Value As Integer) CWKnob.Value = Value lblValue.Caption = CWKnob.Value End Property
0
2482
by: Pierson C | last post by:
A quick easy one! I have a custom user control that has an ArrayList property. I create an instance of the user control, assign all of the properties, but when I add the control to the page, my ArrayList variable has gone out of scope (all int and string properties still exist). It must be where an ArrayList is treated like an Object,...
0
1158
by: jhonz | last post by:
I have come across a strange circumstance. I have user controls with dropdownlists that interact fine during times where the web server has minimal load. But once things pick up and postbacks take longer, my code behind will error out since I expect "ddlSample.SelectedItem.Value" to have a value for a control that exist. But sometimes it...
49
14463
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On http://www.webreference.com/programming/javascript/gr/column9/ they say: <snip> The undefined property A relatively recent addition to JavaScript is the undefined property.
5
2749
by: Mark Ingram | last post by:
Hi, ive written a custom control and i would like to display the "invalid property value" dialog box for certain properties on my form if the user enters a value outside the allowed range (in the visual studio designer). e.g. If i had a percentage property, i would want the user only to be able to enter Int32 values between 0&100. How can...
10
3933
by: John Bailo | last post by:
I want to pass a SqlCommand object as a input parameter to a method. I want to pass the SqlCommand "by value" so that any updates to the original object are *not* reflected in the object within my method. How can I do this?
5
11432
by: emsik1001 | last post by:
Hi I have a few combo boxes where the match is required. When I select a value and then delete it and go to another control then I get very user unfriendly message "invalid property value". I want to allow to go to a different controls if the value is empty and if the value is not in a drop down box I want to either display a user...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.