Can we user webform usercontrols or server controls in MVC?

Hi,

Can we use webform usercontrols (ascx files) in an MVC application?

Generally, is there any online guide that explains best practices  when/how 
webfoms and MVC could be integrated and co-exist?

Thank you,
Allan
 

0
Allan2010
5/5/2010 12:38:40 AM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

3 Replies
658 Views

Similar Articles

[PageSpeed] 2

Allan2010 wrote:
> Hi,
> 
> Can we use webform usercontrols (ascx files) in an MVC application?

A Web usercontrol would have its own MVC implementation, like a Web form 
would have its own MVC implementation. If a usercontrol was accessing 
data from a database, then it would use  its MVC logic (separate logic) 
like the Web form using its MVC logic to access the database that is 
hosting the usercontrol, based on business rules used by each MVC 
controller.

> 
> Generally, is there any online guide that explains best practices  
> when/how webfoms and MVC could be integrated and co-exist?
> 

Maybe, you don't fully understand what the MVC design pattern is about.

What is Model �View- Controller?

(MVC) is an architectural pattern used in software engineering.
Successful use of the pattern isolates business logic from user 
interface considerations,
resulting in an application where it is easier to modify either the 
visual appearance
of the application or the underlying business rules without affecting 
the other.
In MVC, the model represents the information (the data) of the application;
the view corresponds to elements of the user interface such as text, 
checkbox items,
and so forth; and the controller manages the communication of data and the
business rules used to manipulate the data to and from the model.

http://en.wikipedia.org/wiki/Model-view-controller

The best practice is keep the UI dumb. The UI passes controls to the 
'controller' through the 'view' where the controller works with the 
controls to populate or extract data from the controls, based on 
business rules.

You either start off using MVC for the project or you convert an 
existing project to use MVC fully. It's either all or nothing in either 
case.

However, for a given form or usercontrol, one may not be able to 
implement MVC, which is based on a control's behavior of not working or 
not being rendered using MVC. If this is the case, then things with a 
control must be done at the UI at form or usercontrol level, which is 
rare and mainly happens with 3rd party controls.


I don't use MVC myself. I use MVP which can be used for a Windows form 
or a Web form application.

What is Model �View- Presenter?

MVP is a software pattern considered a derivative of the 
Model-view-controller.

http://en.wikipedia.org/wiki/Model_View_Presenter



0
Mr
5/5/2010 5:46:17 AM
Hi Allan,

The two kinds of user control is different. 
The user control in webform is of type System.Web.UI.UserControl while the 
one in MVC is of type System.Web.Mvc.ViewUserControl which is inherited 
from System.Web.UI.UserControl.
Generally speaking, we need to import the following statement in page to 
define a mvc uer control .

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

Besides there is no code behind for MVC user control and no any server 
control conception for MVC.

If you want to mix the traditional ASP.NET and the ASP.NET MVC, you can 
take a look at the following articles.
http://www.packtpub.com/article/mixing-asp.net-webforms-and-asp.net-mvc

http://blogs.imeta.co.uk/MGodfrey/archive/2009/03/31/663.aspx

-- 
Sincerely,
Zhi-Qiang Ni
Microsoft Online Support
==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

MSDN Managed Newsgroup support offering is for non-urgent issues where an 
initial response from the community or a Microsoft Support Engineer within 
2 business day is acceptable. Please note that each follow up response may 
take approximately 2 business days as the support professional working with 
you may need further investigation to reach the most efficient resolution. 
The offering is not appropriate for situations that require urgent, 
real-time or phone-based interactions. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================

0
v
5/5/2010 8:35:56 AM
On May 5, 2:38=A0am, "Allan2010" <Alan2...@nospam.nospam> wrote:
> Hi,
>
> Can we use webform usercontrols (ascx files) in an MVC application?
>
> Generally, is there any online guide that explains best practices =A0when=
/how
> webfoms and MVC could be integrated and co-exist?
>
> Thank you,
> Allan

Hello:
An MVC form don't have a runat=3D"server" tag, MVC page cicle is
completely different from classic asp.net. So, the short answer is no,
you can't use regular asp.net server controls in MVC pages.
0
Cubaman
5/6/2010 8:03:37 AM
Reply:

Similar Artilces:

Can you insert a picture into a specific cell?
Or do they only "float" on the page. Marc They float over the worksheet, but you can adjust the size so that it seems to fit a cell exactly. If you insert a picture, you can hold the alt-key down while you move/resize the picture. When it gets close to the edge of a cell, it'll snap-to that edge. Marc wrote: > > Or do they only "float" on the page. > > Marc -- Dave Peterson ...

Disabled User Issues
Source: MSExchangeIS EventID: 9548 Disabled user does not have a master account SID. Please use Active Directory MMC to set an active account as this user's master account. The problem is, the user account in AD is long gone. Actually, the whole OU where the accounts existed is also long gone. Any way to fix this. All the KB articles seem to be based on the fact that the account still exists. Thanks! Find the 'NoMAS' utility from Microsoft and run it. It will clear these warning messages up. "jspanitz" wrote: > Source: MSExchangeIS > EventID: 9548 &g...

Can't insert Char(1) into SQL Server from Stored Procedure
Hello I am trying to insert a char(1) field into a table from an ASP.Net/C# application. At first I was inserting rows into the table but none of the columns that I was inserting the rows into were char(1) columns, they were mostly int and varchar columns. Then I found out that there was one column in the list that was not supposed to be an int column but instead it was supposed to be one of the char(1) columns into the table. So I replaced the int column in the list with the char(1) column and since the value of the char(1) column resulted from a CheckBox ('Y...

Trouble with Tab Control
I have a form in which i have a tab on it. The problem is the tab appears white and I would like to show the background behind it. I saw in the properties there was a section to make it "transparent" or "normal" i've selected botha nd nothing changes. Any ideas on how to solve this. thanks On Jan 25, 9:32 am, tsla...@gmail.com wrote: > I have a form in which i have a tab on it. The problem is the tab > appears white and I would like to show the background behind it. I > saw in the properties there was a section to make it "transparent" or > ...

Changing SQL Server for CRM 1.2
As my SQL server is currently on its last breath I am in the process of moving our CRM 1.2 databases to a new dedicated serever. I have detatched the databases from the old server, copied the files to the server and attached them. I have then gone into CRM deployment manager and changed to the SQL server to the new server. That all appears to work fine, no error messages. But when users try to access the CRM system they get an error and the CRM server event log fills with error messages. A few are listed below: dmLog: Failed to execute the SQL batch in the file sqlbatch.sql. MSCRM P...

Can E-mail recipient policy be linked to the OU membership?
Running Exchange 2003 (mixed mode) and Windows 2003 server (Windows 2000 mixed mode): I'd like to create a e-mail recipient policy that is linked to the different OU's that are created on the system. Is it possible to link the policy to a specific OU or do I need to create groups on the AD to control which recipients a policy applies to? Martin Moustgaard Yes, you can create a recipient policy that looks to just a specific OU. It is done through LDAP queries. Here are some references to articles and whitepapers that discuss how to work with recipient policies. 249299.KB.EN-US HO...

Can't open 2005 data file after reinstalling Money 2005
I am experiencing a recurring problem. I have had to reinstall Windows XP and MS Money 2005. I am now unable to open my previously converted 2005 file or restore any backup version. I consistently get the following error message: "Money cannot locate filename or cannot open it, possibly because it is a read-only file, you do not have permission to change it, or your disk drive is write- protected. If you have chosen the correct file and it cannot be accessed, you will need to click OK and then Restore your most recent backup file." Any help or thoughts would be greatly ap...

Transferring control of CClientDC to CDC
Hi, I have a class MSWinDisplayManager which I want to take a CClientDC device context so that it's member functions can perform drawing routines on it. I want the class to have it's own CClientDC member which all the methods have access to draw on. My constructor looks like this: MSWinDisplayManager::MSWinDisplayManager(CClientDC& win) { private_win.attach(win); } This is called by the user like: CClientDC dlg(this); MSWinDisplayManager wdm(dlg); then I want to do things like: wdm.drawCars(); The problem I have is that private_win isn't getting control of the device ...

Relay from unstruted server
A certain IIS SMTP server in my company maintained by junior admins got its IP address added to SPAM list at MSN. The junior admins came asking me to allow relay from their insecure server to the Exchange 2000 server that I maintain. My recommendation is that they work with MSN to get their IP address removed from that spam list. Is that likely that MSN/hotmail would remove them from their Spam list ? If so, who would be the contact phone# at MSN to do that ? Do you agree that I should not allow relay from the IIS SMTP to the Exchange server if that IIS box it is not secure and not maintai...

Business Portal Error-SQL server does not exist or access denied
Hi, We are running business portal 4.0 for one of our customer. It was running correctly, however, they have changed the SQL server port (previously it was set as default 1433). After that the business portal becomes very slow and while creating a new request (purchase requisition) if we open the item pop up; it is showing exception "SQL Server does not exist or access denied...." Can any body tell me how can I provide the new port number to business portal connection to the database. Thanks and Regards, Waliullah, Thanks for using the newsgroups. I have a...

Removing multiple users from Outlook
We did some computer switching, which involved uninstalling a copy of Office XP and replacing it with a copy of Office 2003. Now when I open Outlook, it makes me choose a user. This wasn't in the .pst file which was transferred for the other computer, but apparenly it was on this computer someplace. How can I get Outlook to simply open for the one account without that dialog box popping up? Aloha Annie, Control Panel | Mail | Show Profiles...remove any profiles you don't want. Select the one you do want and set it as the default. (if there are more than one left) -Ben-...

Relay Servers?
Is there a free or pay service that will alow me to relay my mail through them? I have a online business and use a cable modem from home. My customers that are with AOL do not recieve my Emails. I figure that i can overcome this if I can relay my mail. TIA Josh Please contact your ISP, maybe they can provide one. As far as I know, AOL and Version has this business. Note: Version's relay server may be not compatible with Exchange server "Josh" <jsawyer@insightbb.com> wrote in message news:ePSn%23r2LFHA.1472@TK2MSFTNGP14.phx.gbl... > Is there a free or pay se...

can i download lxce serv.exe
want to open message lxce serv.exe using windows xp ...

Windows Server 2008 R2 04-09-10
Windows Server 2008 R2 and Windows 7 share the same code? how is that possible when Windows 7 has both 32 bit and 64 bit versions and windows server 2008 r2 is only 64 bit Hello Charle, As Microsoft is going to use only 64bit versions for servers they don't built the 32bit version. Sharing the same code doesn't mean that the server OS use exaclty the same files, there are a lot more and different ones. But the basic code is the same. Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. ...

Microsoft Exchange Server
I am using Outlook 2003 for my emails from microsoft exchange server. A few days back I neede to reinstall my windows. Everything with the installation and configuration goes fine at my outlook 2003 but I am unable to get back all of my inbox and Sent items from my microsoft exchange server. I can see some of the items in my inbox and some in sent items however a lot of things are still missing. Can anyone help for this problem? Early response is highly appreciated. Thankyou all, Best Regards, Rizwan. Submitted using http://www.outlookforums.com Are all messages shown whe...

Shortcut to other user's folders
At our office we view other user's folders by: File:Open:Other user's folder... Is there a way to make a shortcut in the "Outlook Shortcuts" pane on the left to one or more of these user's folders? Thanks! Edit: This is in Outlook 2000 ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ bump, nobody? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from ht...

automaticaly create a variable sized table from user input
Hi, How can I user data input to a cell by a user to create a table with that number of rows. eg. User enters 1024 in B2 165 in B3 12.5 in B4 A10 would contain 1, B10 would contain =B3+(A10*$B$4) A11 would contain 2, B11 would contain =B3+(A11*$B$4) etc to 1024 The user entered number in B2 could be any whole number between 1 and 1024 Thanks, Iain I could make this better but other things to do right now so try this. Uncomment the last line to remove the formula and just leave the values. Sub makeformula() Range("a10") = 1 Range("b10").Formula = "=B3+(A10*$B$4)...

how many receivers i can add
i want to use outlook send 2000 thousands emails to 2000 peoples at the same time. can i put them all in the recivers and send them at one time? thank you for you help ...

IE 7 / Win2k3 x64 server things pop-up blocker is on
I have a problem with one server where it thinks the pop-up block is on when it is actually not. I disable the pop-up blocker for all zones in group policy but I continue to receive messages from websites that pop-ups are disabled and that I need to enable them. I don't understand how this can be the case unless IE is doing something its not telling me about. Any ideas? PS IE ESC is disabled on this server. IE ESC was disabled before terminal services was installed. thanks Pete > ...I continue to receive messages from websites that pop-ups are > disabl...

How do I bind a XAML text box control to a dataset?
Hello; I am new to using WinFx and I am having trouble figuring out how to bind a text box to a field in a dataset. I found an MSDN article: http://msdn2.microsoft.com/en-us/library/ms752057.aspx My question deals with the text box code: <TextBlock Text="{Binding Path=ISBN}" Grid.Column="1" /> How does this text box know to bind to the field "ISBN" in "myDataSet"? How does the control implement the dataset? Thank you Monty ...

Controlling NDR's sent to Originator
Hi, I have a scenario: An Exchange2k User sets up an Auto Forward Rule to forward all inbound mail to a personal email account. This person recieves email into his Inbox and the Rule fires off forwarding the email to their personal account. His personal account is not reachable and Exchange sends a NDR to the original sender. Example: Step 1: john23@example.com sends email to corpuser7@corp14.com Step 2: corpuser7@corp14.com has an Inbox rule that forwards this email to his personal account at homeacct@isporg.com Step 3: exchangeserver.corp14.com recieves an NDR from pubmailer.isporg.c...

2 Domains, 1 Exchange Server
Hi, We're trying to go with 2 seperate 2003 domains, but with only one Exchange 2003 Server. What would be needed for the domain that the Exchange server is not in to access e-mail? We've contemplated having those users use OWA, but would really like them to be able to use Outlook 2003. We're a school district and want to segregate the kids domain from the administration domain, but only have funding for one Exchnage server. Any ideas\help will be appreciated. TIA. Hi, This should explain what it requires: http://support.microsoft.com/?id=278888 Leif "tj woo...

With and import tool can you change only item description?
Is there a way to change only the item description on a large quanity of items. What about the extended description? Thanks for your help. Use the MS SQL Data Import Tool by EMS. $65.00. The QSImport Tool available to download from Microsoft will probably work but is not supported by Microsoft. Kinnard L. Kohler Business Machines Systems 6101 South Shackleford Road Little Rock, AR 72204-8606 (T) 501-375-8380 (F) 501-375-0043 (Cell) 501-412-5686 Email: kinnard@removebmsar.com "Lisa" wrote: > Is there a way to change only the item description on a large quanity of >...

Can i use conditional formating on a cell when it contains a formula?
I am trying a "conditional formatting" on a cell that contains formula, but it didn't work. "If cell value is equal to 0 then font - white" This doesn't work, stays always. If i use this condition on a cell without formula it works just fine. Thank -- si ----------------------------------------------------------------------- sit's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=262 View this thread: http://www.excelforum.com/showthread.php?threadid=26784 Hi are you sure your formula returns an exact zero?. Could you post the formul...

I want to add a mail account without setting a SMTP server. Is it possible?
I want to add a second mail account that is outside my company. Since the company firewall does not allow us to connect to SMTP-servers I want to add this account without setting the SMTP propertiy. I cannot specify the company server as it is an Exchange server and the outside one an IMAP one. Currently I have specified the outside SMTP server since outook does not allow me to add an account wihtout setting this. I keep getting annoying error messages as my computer can't connect to the outside SMTP. Any one know a way around this? cheers, mortb The company server has SMTP enabled, u...