Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 October 12th, 2007, 09:30 AM
Authorized User
 
Join Date: Sep 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default User controls

Hello everybody!!!!

I am trying to customize my own user control. The problem is that I don't know how to work with functions. When I create a function in the .ascx file I don't know how to call it from my .aspx file.

My control has 2 dropdownlists and one textbox. I want to read their values when the user enters new information. I want to do this from my .aspx file (the one that contains my user control)

Thank you in advance!!!

pd. If I want to validate my control, where is it better to do it?
 
Old October 28th, 2007, 12:53 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Hi,

The functions you are creating should be either FRIEND or PUBLIC.
In the aspx file, you will have an object of the user control accessible via the ID of control on your aspx page. Using this object, u can access your functions.

As far as validation is concerned, it should be on the control itself. This is because, as you said that your control is a composite control[has many child controls], but on the aspx page all those will be treated as a single object. The individual validation for each child control in your user control can only be implemented in the user control itself. And it is the recommended way !!

Reading the control values goes the same way, instead of functions, implement the values a s properties, in ascx, then call those properties from aspx.

Anubhav Kumar
 
Old October 28th, 2007, 07:20 PM
Authorized User
 
Join Date: Sep 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot for your kindness
Regards





Similar Threads
Thread Thread Starter Forum Replies Last Post
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
User Controls Lofa ASP.NET 1.0 and 1.1 Basics 2 February 13th, 2006 01:04 PM
User Controls..... Help please cowboy2066 General .NET 2 July 28th, 2004 09:22 AM
User Controls Duncan Pro VB.NET 2002/2003 2 December 1st, 2003 05:41 AM
User Controls Duncan Pro VB.NET 2002/2003 1 October 27th, 2003 12:51 PM





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