473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing argument to user control when creating it

Hi there!

I made own user control for displaying and editing content. In
Page_Load of this control is checked if user is authorized for editing
if so, button for editing is shown, otherwise controll works in
display only mode. I want now use this control to add new content. The
idea is that in another web form, let's call AddNewContent.a spx there
is placed MyContentContro l and I want to run in Editing mode with all
fields reset to defaults. How to do this with asp.net?

Normally I would do this using constructor and passing desired option
to a object during creation, but there are two things:
1. I got strange error when I defined contructor in MyContentContro l,
2. And what's more important, where I am supposed to use this
constructor? In Page_Load of AddNewContent.a spx form it is too late.

Can you help me how to customize control apperance and behaviour
during user controll creation?

Best regards
B.
Sep 16 '08 #1
1 1397

<br********@goo glemail.comwrot e in message
news:c8******** *************** ***********@59g 2000hsb.googleg roups.com...
Hi there!

I made own user control for displaying and editing content. In
Page_Load of this control is checked if user is authorized for editing
if so, button for editing is shown, otherwise controll works in
display only mode. I want now use this control to add new content. The
idea is that in another web form, let's call AddNewContent.a spx there
is placed MyContentContro l and I want to run in Editing mode with all
fields reset to defaults. How to do this with asp.net?
There are a couple of ways to play this game. Depending on your exact needs,
here they are:

1. Add a constructor that contains the properties you need to add. Then,
fire that constructor and add the control at runtime.

2. Change the binding/display at runtime by adding the behavior to the
property you are changing. You can also set properties and create a "re"
render method.
Normally I would do this using constructor and passing desired option
to a object during creation, but there are two things:
1. I got strange error when I defined contructor in MyContentContro l,
What error are you getting?
2. And what's more important, where I am supposed to use this
constructor? In Page_Load of AddNewContent.a spx form it is too late.
In some cases, Page_Load is fine. In others, you have to go to Init. It
really depends on what you are doing. If you use a constructor, it does not
make sense to anchor the control to the page in the tags. This leads to less
than WYSIWYG in the UI, however.

If you add properties, you can set them in backend events, if that is your
desire. You just end up rebinding. Not as efficient, but unless you are
performing serious calculations, the extra cycles should not affect you too
much. If they do, consider a server control, where you can use it a lot more
like a windows control.
Can you help me how to customize control apperance and behaviour
during user controll creation?
The best way, ultimately, is make this a server control. It is a bit of a
pain, but if you have the user control created, it is not a huge amount of
coding to duplicate the look. Makes it far more reusable as well.

Hope this helps.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think outside the box! |
*************** *************** **************

Sep 17 '08 #2

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

Similar topics

2
5313
by: Newbie | last post by:
Hi, I am using creating a drop down menu populated by a call to a postgresql database. The drop down menu is populated correctly (or appears to be) and then upon selecting an item in the menu it is supposed to pass the argument indicated by the menu selection to another php file which uses that argument to make a further (refined) search on the same database. But upon calling the 2nd php file when I try to use the argument passed it...
8
3966
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
3
3280
by: John C | last post by:
Hi, I am a little uncertain about the concept of passing a reference to a class to another instance of a class. for instance I thought that the following was ok: Network network = Network(); Population pool = Population(& network); .... but this doesnt seem to work.. however the following works... Network * network = new Network();
19
4106
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
39
7659
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down indicate: a) That I don't know enough b) Passing arguments by ref is bad
6
3949
by: Max | last post by:
Last time I tried to explain this on another forum it didn't go too well, so I'll try my best and if you know what I'm talking about then please tell me how to do this. I have a class, inside I have some public functions and private variables. Inside the class I also have a declaration of a new form object. One of the functions of the class takes that form object, shows it with showdialog and the basically passes the control to the form...
12
2591
by: dave_dp | last post by:
Hi, I have just started learning C++ language.. I've read much even tried to understand the way standard says but still can't get the grasp of that concept. When parameters are passed/returned by value temporaries are created?(I'm not touching yet the cases where standard allows optimizations from the side of implementations to avoid copying) If so, please quote part of the standard that says that. Assuming it is true, I can imagine two...
1
1520
by: Dom | last post by:
In VB I was able (I think, it's been a long time after all) to pass a Form as an argument to a procedure, and then within that procedure, to access the controls. For example, public void MyProc (frmMain f) if (f.OptionButton.value = 1) ... It seems I can't do this in CSharp. What do you do to take it's place? I have several controls I need to check in the method.
1
1191
by: Nathan Sokalski | last post by:
I have finally figured out how to create transparency in GIF files when creating them with VB.NET (it is harder than I think it should be, but at least I can do it now). I would like to write a couple functions and/or subroutines to make this easier. However, when I pass a Bitmap as a parameter it does not include the data from the Palette property. I have also tried passing the Palette as a separate argument, but the same problem...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9200
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.