Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey,
1)my problem is that i want to access and calling user control from code behind file and display at particular column of my page.
2) i want to set privileges of same user control for different user of my site.

Thanks
Bilal Hassan
Posted
Comments
Hemant__Sharma 3-May-11 4:27am    
Please clarify: when you are saying accessing user control are you saying adding it directly to the codebehind and accessing it at runtime?

When you are saying particular column do you mean you want to add it to gridview or some data control?

Set privileges for different user? what does that mean? is it like you want to hide/show based on the user logged in to the page?
bilal _hassan 3-May-11 11:56am    
Hemant-Sharma-81: thanks for your concern and you are right,
1)yes i want to add usercontrol directly and access in at run time.
2) yes there is a Place Holder on my page where i want to show usercontrol.
3) different user includes (Admin, Staff, and students) so i want hide/show based according to user.
Sergey Alexandrovich Kryukov 22-Jan-13 15:43pm    
Please don't post your comments as solutions.
—SA

Well,

there are many links can tell you how to add user control at runtime, here is one:
http://www.beansoftware.com/ASP.NET-Tutorials/Controls-Run-Time.aspx[^]
if the above link doesn't help you google for "add user control at runtime asp.net" you will find thousands of links.

For condition logic you can simply put If...usertype==Admin kind of code and take action to add or not to add the user control.

Thanks,
Hemant
 
Share this answer
 
Comments
bilal _hassan 7-May-11 16:08pm    
Thankssss alot
Hemant__Sharma 8-May-11 5:03am    
I'm glad i could help.
Your question is not very clear, however you should be able to use a usercontrol in your code once you have added the proper namespaces .
 
Share this answer
 
v2
Put a place holder and load the control dynamically. It can be done from code behind, so that you can put your code in conditional statement and authenticate user accordingly.

Another solution is to use if-else block directly in the source, and check whether user is permitted to view the control or not.

Hope you got my point...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900