Solved

User Control - runat="server"

Posted on 2014-09-18
6
148 Views
Last Modified: 2014-10-03
I created a user control.   When I drop it on the page, it tells me it needs the runat="server" attribute.  How can I code the control itself so it has runat="server"?
0
Comment
Question by:HLRosenberger
  • 3
  • 2
6 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 333 total points
ID: 40330451
A user control is a module that you drop on another page.

When you register the control on the page and create an instance of that control, you have to tell the page to run the instance at the server.

There's no way I know of to get around putting in runat="server".  What are you trying to accomplish by not having it there?
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 40330459
I do want it there.  I just was hoping to not have to add it when I put it on the page, but instead code it right within the control. This is my own control I have written, not a third party thing.
0
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 333 total points
ID: 40330473
Understood, but the page still needs to know that your control should be runat = server.  There's no way around that.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 40330642
ok.   thanks.
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 167 total points
ID: 40338405
Hey its not possible to use the user control without runat=server
Because these controls are derived from System.Web.UI.UserControl class
And if you remove the runat=server property then it gives you only warning but it will not be rendered on the page.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40359754
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now