Wrox Programmer Forums
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 27th, 2003, 04:01 AM
Registered User
Join Date: Aug 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Client-sided control example?

I need an example to understand the client-sided control

For example ;

I need a (I think a javascript code) in a ascx file

Then in a web form I want to write the Listbox1.selecteditem.text to the textbox1.text

I do not have enough informtaion about this subject.

I heard about a Render method but not know anything

is there a good informtaion about this subject? or could you please send me an example?

Please help.
Old August 30th, 2003, 12:03 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

Using ASP.NET, there is no real need to do this with JavaScript (well, you could, but you don't have to).

Here's a short example of what I think might help:

Add the following code to an ASPX page, between the <form> tags:

<asp:ListBox id=ListBox1 runat="server" Width="151px" Height="100px" Rows="5"></asp:ListBox>
<asp:Button id=Button1 runat="server" Text="Send"></asp:Button>
<asp:Label id=Label1 runat="server"></asp:Label>
This code sets up a Listbox to hold the various choices, a Button that the user can click to submit their choice to the server, and a Label to display the text of the selected item.

Then, in your Code Behind file, add the following code:

private void Page_Load(object sender, System.EventArgs e)
    if (!IsPostBack)
        String[] arrTest = new String[3];
        arrTest[0] = "Apples";
        arrTest[1] = "Oranges";
        arrTest[2] = "Pears";
        ListBox1.DataSource = arrTest;

private void Button1_Click(object sender, System.EventArgs e)
    Label1.Text = ListBox1.SelectedItem.Text;
At run time, when the page is requested for the first time (IsPostBack is not true), an array is declared, 3 items are added and then the array is assigned to the Listbox.

When the user clicks the button, the text of the selected item is displayed on the Label.

Note that this is just a simple example. For more information, I suggest you take a look at the Quick Start examples that come with the .NET Framework SDK.

If you have more questions (or need help with a VB.NET instead of a C# solution), feel free to post them here.



Imar Spaanjaars
Everyone is unique, except for me.

Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting client to client (Socket programming) maricar C# 0 September 25th, 2008 04:34 AM
How to put a button control in a GridView control ryan.webb ASP.NET 2.0 Basics 2 December 28th, 2007 05:26 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM
ASP.NET Calendar Control Client Side Access rodmcleay ASP.NET 1.0 and 1.1 Basics 4 June 17th, 2005 11:45 PM
Custom Validation Control Client side event rodmcleay ASP.NET 1.0 and 1.1 Basics 3 December 17th, 2004 08:47 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.