Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
1) How we will specify in user control behave differently for two web pages.
 
2) As i have one user control which is to be used in two webpages.But i need to make some controls to be invisible.
Posted 16-Feb-13 19:19pm
Edited 16-Feb-13 19:45pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

can we use one user control in multiple asp.net webpage by making some controls invisible
Yes.
 
How we will specify in user control behave differently for two web pages.
By exposing controls via defining user control public properties or using FindControl method. Once you have reference to the control, set the visibility.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Your user control can take parameters so that each page can pass different parameters. Depending on this parameter, you can turn on/off features in the control.
 
Eg:
<user:MyControl id="myUserControl" runat="server" CustomProperty="Some Value" ></user:MyControl>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You must create parameters in User Control on behalf of those parameters you can hide/show controls.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

means u want to make controls visibility as per ur requirements, which u have added in user control.
then u have to declare property in user control using get set assign them to control
 
i.e if u have button in user control and u want to make is visible false as per ur requirements ,Then create property
public bool BtnVisibility
{
get
{
}
set
{
btn1.Visible= value;
}
}
 

value for visibility u have to pass from page where u have added ur user control
like follows
MyUserControl.BtnVisibility = false;
 
refer following article.They have created user control and assing values to lable on page.Same way do for control visibility.
http://www.dotnetfunda.com/articles/article16.aspx[^]
  Permalink  
Comments
Member 9840927 at 17-Feb-13 11:43am
   
Thank u but i am not getting user control name in aspx page error like it is a field but used as type
Pallavi waikar at 17-Feb-13 11:51am
   
have u added reference of that user control on ur page..and also check for runat attribute <myCtr.MyUserControl id="MyUserControl" runat="server"/> in .aspx page...for help check following link. http://msdn.microsoft.com/en-us/library/c0az2h86%28v=vs.100%29.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Marcin Kozub 310
1 OriginalGriff 248
2 Sergey Alexandrovich Kryukov 215
3 Richard MacCutchan 202
4 Praneet Nadkar 197
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100