Search Results

Search found 427 results on 18 pages for 'ascx'.

Page 3/18 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Alternatives to ASCX User Control without a server-side form?

    - by Andrew Murray
    I've got an ASP.NET 3.5 Web Forms application in which a large chunk of code needs to be duplicated between a few different pages. Sounds like the ideal candidate for a user-control right? Problem is, this cannot be contained within a <form runat="server"> because it contains a client-side form of it's own. There are no runat=server controls or postbacks or anything that really need that webform - think of it just as a chunk of HTML with a few basic <% %> tags. I'd just want to set a property on the control when it's loaded, so that it knows what to output. This is purely an exercise to make the code easier to maintain. Before I resort to using an oldskool <!--#include-->, is there some better way of doing this?

    Read the article

  • Issue with dynamically loading a user control on button click

    - by Kumar
    I have a page in which I am loading a user control dynamically as follows: Default.aspx: <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </cc1:ToolkitScriptManager> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> Default.aspx.cs: protected void Page_Load(object sender, EventArgs e) { var ctrl = LoadControl("~/UserCtrl1.ascx"); ctrl.ID = "ucUserCtrl1"; PlaceHolder1.Controls.Add(ctrl); } Below is the code for UserCtrl1.ascx <asp:Label ID="Label1" runat="server"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" /> <br /> <asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder> I am dynamically loading another user control when the Button1 is clicked UserCtrl1.ascx.cs protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "UserControl - 1 button clicked!"; var ctrl = LoadControl("~/UserCtrl2.ascx"); ctrl.ID = "ucUserCtrl2"; PlaceHolder2.Controls.Add(ctrl); } Below is the markup for UserCtrl2.ascx <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server"></asp:Label> <asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" /> </ContentTemplate> </asp:UpdatePanel> UserCtrl2.ascx.cs protected void Button2_Click(object sender, EventArgs e) { Label2.Text = "UserControl - 2 button clicked!"; } After the page loads when I click the Button1 in UserCtrl1 the click event fires and I am able to see the Label1 text. It also properly loads the UserCtrl2, but when I click the Button2 in UserCtrl2 the click event dosent fire and even worse when I click the Button2 twice the UserCtrl2 control dissappears from the page. How can I fix this?

    Read the article

  • ASP.NET Wizard control with Dynamic UserControls

    - by wjat777
    Hello everyone I'm trying to use the Wizard control as follows: 1 - In the first step (first screen) has a cheklistbox with several options 2 - For each option selected, will be created an extra step 3 - In some steps may be set up intermediate stages Me problem is that each step is a usercontrol. So if the first step I select option1 and option3, I should create two more steps with usercontrol1 and UserControl3 .... Someone already did something similar? I will try explain better the problem. I'll paste here, but I put a copy of the project in skydrive: http://cid-3d949f1661d00819.skydrive.live.com/self.aspx/C%5E3/WizardControl2.7z It is a very basic example of what I'm trying to do. The project has page.ASPX 1 and 3 usercontrol.ASCX (UC1, UC2 and UC3) Default.ASPX: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" % Option1 Option2 Option3 Code Behind: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Page_PreInit(object sender, EventArgs e) { LoadSteps(); } private void LoadSteps() { int count = Wizard1.WizardSteps.Count; for (int i = count - 1; i > 0; i--) { WizardStepBase step = Wizard1.WizardSteps[i]; if (step.StepType != WizardStepType.Start) Wizard1.WizardSteps.Remove(step); } string Activities=""; foreach (ListItem item in CheckBoxList1.Items) { if (item.Selected) { WizardStep step = new WizardStep {ID = "step_" + item.Value, Title = "step_" + item.Value}; UserControl uc=null; switch (item.Value) { case "1": uc=(UserControl)LoadControl("~/UC1.ascx"); break; case "2": uc=(UserControl)LoadControl("~/UC2.ascx"); break; case "3": uc=(UserControl)LoadControl("~/UC3.ascx"); break; } step.Controls.Add(uc); Wizard1.WizardSteps.Add(step); } } } protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) { LoadSteps(); } } } Control UC1.ASCX to UC3.ASCX has the same code (as an example) usercontrol.ascx: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UC1.ascx.cs" Inherits="WebApplication2.UC1" % AutoPostBack="True" AutoPostBack="True" Code Behind: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class UC1 : System.Web.UI.UserControl { protected void Page_Init(object sender, EventArgs e) { List list1 = new List { "Alice", "Bob", "Chris" }; List list2 = new List { "UN", "DEUX", "TROIS" }; DropDownList1.DataSource = list1; DropDownList2.DataSource = list2; DropDownList1.DataBind(); DropDownList2.DataBind(); } protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = DropDownList1.SelectedValue; } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { Label2.Text = DropDownList2.SelectedValue; } } } You can see that the controls UserControls trigger events (they cause postbacks) The behavior of this project is a little different than I described in the first thread, but the problem is the same. After the second time "next" button, you will get an error. Thanks in advance William

    Read the article

  • How to get a safecontrol entry into manifest.xml with WSPBuilder project

    - by andrew
    Upon taking the default sharepoint master page for MySite, making some changes, and making a wsp out of it with WSPBuilder, I come to these errors in my logs: http://spoint/MySite/%5Fcatalogs/masterpage/MySite.master - An unexpected error has been encountered in this Web Part. Error: The control with virtual path '_controltemplates/Welcome.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite'., Source: [UnsafeControlException: The control with virtual path '_controltemplates/Welcome.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite' (stack trace omitted) http://spoint/MySite/%5Fcatalogs/masterpage/MySite.master - An unexpected error has been encountered in this Web Part. Error: The control with virtual path '_controltemplates/DesignModeConsole.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite'., Source: [UnsafeControlException: The control with virtual path '_controltemplates/DesignModeConsole.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite' (stack trace ommited) So, this masterpage does in fact use these OOTB controls and so I guess I need to get them safecontrolled. And I guess I want to do this via the manifest.xml. But I do not see how to make WSPBuilder do this.

    Read the article

  • getting base url of web site's root (absolute/relative url)

    - by uzay95
    I want to completely understand how to use relative and absolute url address in static and dynamic files. ~ : / : .. : in a relative URL indicates the parent directory . : refers to the current directory / : always replaces the entire pathname of the base URL // : always replaces everything from the hostname onwards This example is easy when you are working without virtual directory. But i am working on virtual directory. Relative URI Absolute URI about.html http://WebReference.com/html/about.html tutorial1/ http://WebReference.com/html/tutorial1/ tutorial1/2.html http://WebReference.com/html/tutorial1/2.html / http://WebReference.com/ //www.internet.com/ http://www.internet.com/ /experts/ http://WebReference.com/experts/ ../ http://WebReference.com/ ../experts/ http://WebReference.com/experts/ ../../../ http://WebReference.com/ ./ http://WebReference.com/html/ ./about.html http://WebReference.com/html/about.html I want to simulate a site below, like my project which is working on virtual directory. These are my aspx and ascx folder http://hostAddress:port/virtualDirectory/MainSite/ASPX/default.aspx http://hostAddress:port/virtualDirectory/MainSite/ASCX/UserCtrl/login.ascx http://hostAddress:port/virtualDirectory/AdminSite/ASPX/ASCX/default.aspx These are my JS Files(which will be use both with the aspx and ascx files): http://hostAddress:port/virtualDirectory/MainSite/JavascriptFolder/jsFile.js http://hostAddress:port/virtualDirectory/AdminSite/JavascriptFolder/jsFile.js this is my static web page address(I want to show some pictures and run inside some js functions): http://hostAddress:port/virtualDirectory/HTMLFiles/page.html this is my image folder http://hostAddress:port/virtualDirectory/Images/PNG/arrow.png http://hostAddress:port/virtualDirectory/Images/GIF/arrow.png if i want to write and image file's link in my ASPX file i should write aspxImgCtrl.ImageUrl = Server.MapPath("~")+"/Images/GIF/arrow.png"; But if i want to write the path hard coded or from javascript file, what kind of url address it should be?

    Read the article

  • How to check if returning View is of type PartialViewResult or a ViewUserControl

    - by mare
    In the method FindView() I have to somehow check if the View we are requesting is a ViewUserControl. Because otherwise I get an error saying: "A master name cannot be specified when the view is a ViewUserControl." This is my custom view engine code right now: public class PendingViewEngine : VirtualPathProviderViewEngine { public PendingViewEngine() { // This is where we tell MVC where to look for our files. /* {0} = view name or master page name * {1} = controller name */ MasterLocationFormats = new[] {"~/Views/Shared/{0}.master", "~/Views/{0}.master"}; ViewLocationFormats = new[] { "~/Views/{1}/{0}.aspx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx", "~/Views/{1}/{0}.ascx" }; PartialViewLocationFormats = new[] {"~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.ascx"}; } protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) { return new WebFormView(partialPath, ""); } protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) { return new WebFormView(viewPath, masterPath); // this line produces the error because we cannot set master page on ASCXs, so I need an "if" here } public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { if (controllerContext.HttpContext.Request.IsAjaxRequest()) return base.FindView(controllerContext, viewName, "Modal", useCache); return base.FindView(controllerContext, viewName, "Site", useCache); } } The above ViewEngine fails on calls like this: <% Html.RenderAction("Display", "MyController", new { zoneslug = "some-zone-slug" });%> The action I am rendering here is this: public ActionResult Display(string zoneslug) { WidgetZone zone; if (!_repository.IsUniqueSlug(zoneslug)) zone = (WidgetZone) _repository.GetInstance(zoneslug); else { // do something here } // WidgetZone used here is WidgetZone.ascx, so a partial return View("WidgetZone", zone); } I cannot use RenderPartial because you cannot send route values to RenderPartial the way you can to RenderAction. To my knowledge there is no way to provide RouteValueDictionary to RenderPartial() like the way you can to RenderAction().

    Read the article

  • ASP:NET :Problem in DoNut Caching

    - by Shyju
    I have an ASP.NET page where i am trying to do some output caching.But ran into a problem. My ASPX page has <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MYProject._Default" %> <%@ OutputCache Duration="600" VaryByParam="None" %> <%@ Register TagPrefix="MYProjectUC" TagName="PageHeader" Src="~/Lib/UserControls/PageHeader.ascx" %> <%@ Register TagPrefix="MYProjectUC" TagName="PageFooter" Src="~/Lib/UserControls/PageFooter.ascx" %> and i have used the User control called "PageHeader" in the aspx page. In PageHeader.ascx, i have an asp.net substitution control, where i want to show some links based on the logged in user. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PageHeader.ascx.cs" Inherits="MyProject.Lib.UserControls.PageHeader1" %> <div class="headerRow"> <div class="headerLogo"> <a href="Default.aspx"><img src="Lib/Images/header.gif" alt=""></a> </div> <div id="divHeaderMenu" runat="server"> <asp:Substitution ID="subLinks" runat="server" MethodName="GetUserProfileHeaderLinks" /> </div> </div><!--headerRow--> In my ascx.cs file,i have a static method which will return a string based on whether the used logged in or not using session public static string GetUserProfileHeaderLinks(HttpContext context) { string strHeaderLinks = string.Empty; // check session and return string return strHeaderLinks; } But Still the page shows the same content for both logged in user and Guest user. My objective is to to have the Page being cached except the content inside the substitution control. Any idea how to achieve this ? Thanks in advance

    Read the article

  • How do I retrieve the values entered in a nested control added dynamically to a webform?

    - by Front Runner
    I have a date range user control with two calendar controls: DateRange.ascx public partial class DateRange { public string FromDate { get { return calFromDate.Text; } set { calFromDate.Text = value; } } public string ToDate { get { return calToDate.Date; } set { calToDate.Text = value; } } } I have another user control in which DateRange control is loaded dynamically: ParamViewer.ascx public partial class ParamViewer { public void Setup(string sControlName) { //Load parameter control Control control = LoadControl("DateRange.ascx"); Controls.Add(control); DateRange dteFrom = (DateRange)control.FindControl("calFromDate"); DateRange dteTo = (DateRange)control.FindControl("calToDate"); } } I have a main page webForm1.aspx where ParamViewer.ascx is added When user enter the dates, they're set correctly in DateRange control. My question is how how do I retrieve the values entered in DateRange (FromDate and ToDate)control from btnSubmit_Click event in webForm1? Please advise. Thank you in advance.

    Read the article

  • Missing Intellisense While Describing Custom Control Properties Declaratively

    - by Albert Bori
    So, I've been working on this project for a few days now, and have been unable to resolve the issue of getting intellisense support for my custom-defined inner properties for a user control (ascx, mind you). I have seen the solution to this (using server controls, .cs mind you) many times. Spelled out in this article very well. Everything works for me while using ascx controls except intellisense. Here's the outline of my code: [PersistChildren(true)] [ParseChildren(typeof(BreadCrumbItem))] [ControlBuilder(typeof(BreadCrumbItem))] public partial class styledcontrols_buttons_BreadCrumb : System.Web.UI.UserControl { ... [PersistenceMode(PersistenceMode.InnerDefaultProperty)] public List<BreadCrumbItem> BreadCrumbItems { get { return _breadCrumbItems; } set { _breadCrumbItems = value; } } ... protected override void AddParsedSubObject(object obj) { base.AddParsedSubObject(obj); if (obj is BreadCrumbItem) BreadCrumbItems.Add(obj as BreadCrumbItem); } ... public class BreadCrumbItem : ControlBuilder { public string Text { get; set; } public string NavigateURL { get; set; } public override Type GetChildControlType(string tagName, System.Collections.IDictionary attribs) { if (String.Compare(tagName, "BreadCrumbItem", true) == 0) { return typeof(BreadCrumbItem); } return null; } } } Here's my mark up (which works fine, just no intellisense on the child object declarations): <%@ Register src="../styledcontrols/buttons/BreadCrumb.ascx" tagname="BreadCrumb" tagprefix="uc1" %> ... <uc1:BreadCrumb ID="BreadCrumb1" runat="server" BreadCrumbTitleText="Current Page"> <BreadCrumbItem Text="Home Page" NavigateURL="~/test/breadcrumbtest.aspx?iwentsomewhere=1" /> <BreadCrumbItem Text="Secondary Page" NavigateURL="~/test/breadcrumbtest.aspx?iwentsomewhere=1" /> </uc1:BreadCrumb> I think the issue lies with how the intellisense engine traverses supporting classes. All the working examples I see of this are not ascx, but Web Server Controls (cs, in a compiled assembly). If anyone could shed some light on how to accomplish this with ascx controls, I'd appreciate it.

    Read the article

  • Control within another control in asp.net disables server-side events?

    - by Xaisoft
    I have a control which has a button on it. All the button does is redirect the user to another page. On this control I have another control which just display some stuff, nothing fancy. When I click on the button, it does nothing. When I remove or comment out the other control, the button event works. Is this by design? I am not sure how to fix it or what is causing it. ControlA.ascx contains a button with an event like so: protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("~/Home.aspx"); } ControlA.ascx contains another control inside of it, lets call it ControlB.ascx. The Button1 click event does not fire when ControlB.ascx is in ControlA.ascx, but when I remove it or take it out, Button1 event fires and it goes to Home.aspx. This does not only happen for Button1, if I decide to add a second button and create an event for it, if ControlB is in ControlA, the second button event won't fire either.

    Read the article

  • Get Row of DataGrid in User Control Page

    - by Romil
    My Question is related to access the rows in one page and putting conditions in another page. I need to check whether a datagrid has row in it or not. DataGrid is in .aspx page. Based on this checking i need to write a condition in .ascx page. the .ascx on which condition is checked is linked to .aspx page. Meaning that UserControl1.ascx is Register with Default.aspx page I am using VS 2003 Please advice Thanks

    Read the article

  • Loading a Template From a User Control

    - by Ricardo Peres
    What if you wanted to load a template (ITemplate property) from an external user control (.ascx) file? Yes, it is possible; there are a number of ways to do this, the one I'll talk about here is through a type converter. You need to apply a TypeConverterAttribute to your ITemplate property where you specify a custom type converter that does the job. This type converter relies on InstanceDescriptor. Here is the code for it: public class TemplateTypeConverter: TypeConverter { public override Boolean CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return ((sourceType == typeof(String)) || (base.CanConvertFrom(context, sourceType) == true)); } public override Boolean CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return ((destinationType == typeof(InstanceDescriptor)) || (base.CanConvertTo(context, destinationType) == true)); } public override Object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType) { if (destinationType == typeof(InstanceDescriptor)) { Object objectFactory = value.GetType().GetField("_objectFactory", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(value); Object builtType = objectFactory.GetType().BaseType.GetField("_builtType", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(objectFactory); MethodInfo loadTemplate = typeof(TemplateTypeConverter).GetMethod("LoadTemplate"); return (new InstanceDescriptor(loadTemplate, new Object [] { "~/" + (builtType as Type).Name.Replace('_', '/').Replace("/ascx", ".ascx") })); } return base.ConvertTo(context, culture, value, destinationType); } public static ITemplate LoadTemplate(String virtualPath) { using (Page page = new Page()) { return (page.LoadTemplate(virtualPath)); } } } And, on your control: public class MyControl: Control { [Browsable(false)] [TypeConverter(typeof(TemplateTypeConverter))] public ITemplate Template { get; set; } } This allows the following declaration: Hope this helps! SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.brushes.Xml.aliases = ['xml']; SyntaxHighlighter.all();

    Read the article

  • Asp.net MVC jquery-ajax dont render html

    - by Troublesum
    Hi, Im trying to use jqeury ajax with MVC i can get it to post back to the action i want and it returns the ViewData objects with updated Data but never renders the HTML. I have i View which contains some MVC User Controls and i want them to update on a timer. Here is my View Markup <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/PageWithSummaryViewAndTabs.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="FullCaseTitle" ContentPlaceHolderID="TitleContent" runat="server"> </asp:Content> <asp:Content ID="FullCaseContent" ContentPlaceHolderID="MainContent" runat="server"> <script type="text/javascript"> window.setInterval(test, 5000); function test() { jQuery.get("/PatientCase/RefreshEPRF", function(response) { }); } </script> <div id="loadingDiv" style="display:none">Updating</div> <input id="refreshPatientCaseIndexButton" type="submit" visible="true" title="refresh" value="Refresh" /> <h2>Full Case</h2> <div id="EPRFContent"> <%Html.RenderPartial(@"~/Views/PatientCase/SectionEPRF.ascx"); %> <%Html.RenderPartial(@"~/Views/PatientCase/SectionDrugs.ascx"); %> </div> <div id="ImageContent"> <%Html.RenderPartial(@"~/Views/PatientCase/SectionImagery.ascx"); % On postback i call a Action Called RefreshEPRF which loads just the required user controls again <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%Html.RenderPartial(@"~/Views/PatientCase/SectionEPRF.ascx"); %> <%Html.RenderPartial(@"~/Views/PatientCase/SectionDrugs.ascx"); %> And finaly the marpup in the control <table id="detailstable"> <tr><td id="detailslablecolumn">Patient Name : </td><td> <% foreach (var item in (List<STS_Lite.Models.PatinetCase.EPRFItem>)ViewData["EPRF"]) { if (item.datumItemId == 46) { if (item.Stroke) { %> <img src="/PatientCaseIndex/InkImageData/GetInkImage/<%=ViewData["PatientCaseId"]%>/<%=ViewData["TemplateInstanceId"]%>/<%=item.TemplateItemId %>" /> <% } else {%> <%=item.Value.ToString()%> <%} break; } } %></td></tr><table> When i step through this code the ViewData in the user control has the new updated values but the page comes back with no new values. I have tried the jquery.get and ajax but with no luck. Any help would be great thanks

    Read the article

  • ASP.Net MVC View and Controller file structure

    - by Jit
    I am very confused the View and corresponding controller has to be set in MVC 1.0 project structure. Currently in a default application we have About.aspx page under Home folder and all the controller action is handled in HomeController. This controller mixes up Home action and About action. It makes things messy. I like to have clear separation of my controller. Like to have one About Controller and HomeCotroller separately. For it I have create another folder "About" under view folder and place Aboput.aspx in it , otherwise we will get the error below. How can I achieve it ?? I like to have exact folder structure as in View, same as in Cotroller. The view 'About' or its master could not be found. The following locations were searched: ~/Views/About/About.aspx ~/Views/About/About.ascx ~/Views/Shared/About.aspx ~/Views/Shared/About.ascx Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The view 'About' or its master could not be found. The following locations were searched: ~/Views/About/About.aspx ~/Views/About/About.ascx ~/Views/Shared/About.aspx ~/Views/Shared/About.ascx I like to have folders like \iew\About.aspx and Cotroller\AboutController.cs or \View\Info\About.aspx and \Controller\Info\AboutController.cs. This will make my project and code very cleanly placed and good to maintain. Thanks in advance for helping

    Read the article

  • Can an ASP.NET user control determine its context or its parent .aspx file

    - by John Galt
    Is it possible for a user control to determine its "context" or its parent .aspx page in some way? Right now I have a user control that is declared on a typical .aspx page as follows: <%@ Register TagPrefix="uc1" TagName="ManageTitle" Src="../UserControls/ManageTitle.ascx" %> The user control currently emits a textbox as follows: <asp:textbox id="txtTitle" runat="server" MaxLength="60" ToolTip="Describe the item with a short pithy title - most important keywords first"/> The page_load for this .ascx file is currently like this: Me.txtTitle.Text = SetPageTitle() While some places in this web app need this (i.e. a textbox where end-user can type a "title"), I have other places where I want to show the "title" information in a "read-only" way. For example, rather than a textbox, I could use a label control or a textbox with Enabled="false" to prevent data entry. I suppose I could clone this small .ascx file and append a suffix to its name like _RO.ascx or something but I am wondering what the best approach would be. In short, can a user control get some sort of "context" from the page that declares it or is there an altogether better way to accomplish this sort of thing? Thank you.

    Read the article

  • Custom View Engine in ASP.NET MVC 2 does not work with Areas

    - by mare
    I used the code below so far with ASP.NET MVC v1 and v2 but when I added an Area today to my application, the controller for the area couldn't find any views in my Areas/Views/controllerView folder. It issued the very well known exception that it searched those 4 standard folders but it did not look under Areas.. How can I change the code so that it will work with Areas? Maybe an example of custom view engine under ASP.NET MVC 2 with Areas support? The information about it on the net is very scarse.. Here's the code: public class PendingViewEngine : VirtualPathProviderViewEngine { public PendingViewEngine() { // This is where we tell MVC where to look for our files. /* {0} = view name or master page name * {1} = controller name */ MasterLocationFormats = new[] {"~/Views/Shared/{0}.master", "~/Views/{0}.master"}; ViewLocationFormats = new[] { "~/Views/{1}/{0}.aspx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx", "~/Views/{1}/{0}.ascx" }; PartialViewLocationFormats = new[] {"~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.ascx"}; } protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) { return new WebFormView(partialPath, ""); } protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) { return new WebFormView(viewPath, masterPath); } }

    Read the article

  • MVC Portable Area Modules *Without* MasterPages

    - by Steve Michelotti
    Portable Areas from MvcContrib provide a great way to build modular and composite applications on top of MVC. In short, portable areas provide a way to distribute MVC binary components as simple .NET assemblies where the aspx/ascx files are actually compiled into the assembly as embedded resources. I’ve blogged about Portable Areas in the past including this post here which talks about embedding resources and you can read more of an intro to Portable Areas here. As great as Portable Areas are, the question that seems to come up the most is: what about MasterPages? MasterPages seems to be the one thing that doesn’t work elegantly with portable areas because you specify the MasterPage in the @Page directive and it won’t use the same mechanism of the view engine so you can’t just embed them as resources. This means that you end up referencing a MasterPage that exists in the host application but not in your portable area. If you name the ContentPlaceHolderId’s correctly, it will work – but it all seems a little fragile. Ultimately, what I want is to be able to build a portable area as a module which has no knowledge of the host application. I want to be able to invoke the module by a full route on the user’s browser and it gets invoked and “automatically appears” inside the application’s visual chrome just like a MasterPage. So how could we accomplish this with portable areas? With this question in mind, I looked around at what other people are doing to address similar problems. Specifically, I immediately looked at how the Orchard team is handling this and I found it very compelling. Basically Orchard has its own custom layout/theme framework (utilizing a custom view engine) that allows you to build your module without any regard to the host. You simply decorate your controller with the [Themed] attribute and it will render with the outer chrome around it: 1: [Themed] 2: public class HomeController : Controller Here is the slide from the Orchard talk at this year MIX conference which shows how it conceptually works:   It’s pretty cool stuff.  So I figure, it must not be too difficult to incorporate this into the portable areas view engine as an optional piece of functionality. In fact, I’ll even simplify it a little – rather than have 1) Document.aspx, 2) Layout.ascx, and 3) <view>.ascx (as shown in the picture above); I’ll just have the outer page be “Chrome.aspx” and then the specific view in question. The Chrome.aspx not only takes the place of the MasterPage, but now since we’re no longer constrained by the MasterPage infrastructure, we have the choice of the Chrome.aspx living in the host or inside the portable areas as another embedded resource! Disclaimer: credit where credit is due – much of the code from this post is me re-purposing the Orchard code to suit my needs. To avoid confusion with Orchard, I’m going to refer to my implementation (which will be based on theirs) as a Chrome rather than a Theme. The first step I’ll take is to create a ChromedAttribute which adds a flag to the current HttpContext to indicate that the controller designated Chromed like this: 1: [Chromed] 2: public class HomeController : Controller The attribute itself is an MVC ActionFilter attribute: 1: public class ChromedAttribute : ActionFilterAttribute 2: { 3: public override void OnActionExecuting(ActionExecutingContext filterContext) 4: { 5: var chromedAttribute = GetChromedAttribute(filterContext.ActionDescriptor); 6: if (chromedAttribute != null) 7: { 8: filterContext.HttpContext.Items[typeof(ChromedAttribute)] = null; 9: } 10: } 11:   12: public static bool IsApplied(RequestContext context) 13: { 14: return context.HttpContext.Items.Contains(typeof(ChromedAttribute)); 15: } 16:   17: private static ChromedAttribute GetChromedAttribute(ActionDescriptor descriptor) 18: { 19: return descriptor.GetCustomAttributes(typeof(ChromedAttribute), true) 20: .Concat(descriptor.ControllerDescriptor.GetCustomAttributes(typeof(ChromedAttribute), true)) 21: .OfType<ChromedAttribute>() 22: .FirstOrDefault(); 23: } 24: } With that in place, we only have to override the FindView() method of the custom view engine with these 6 lines of code: 1: public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) 2: { 3: if (ChromedAttribute.IsApplied(controllerContext.RequestContext)) 4: { 5: var bodyView = ViewEngines.Engines.FindPartialView(controllerContext, viewName); 6: var documentView = ViewEngines.Engines.FindPartialView(controllerContext, "Chrome"); 7: var chromeView = new ChromeView(bodyView, documentView); 8: return new ViewEngineResult(chromeView, this); 9: } 10:   11: // Just execute normally without applying Chromed View Engine 12: return base.FindView(controllerContext, viewName, masterName, useCache); 13: } If the view engine finds the [Chromed] attribute, it will invoke it’s own process – otherwise, it’ll just defer to the normal web forms view engine (with masterpages). The ChromeView’s primary job is to independently set the BodyContent on the view context so that it can be rendered at the appropriate place: 1: public class ChromeView : IView 2: { 3: private ViewEngineResult bodyView; 4: private ViewEngineResult documentView; 5:   6: public ChromeView(ViewEngineResult bodyView, ViewEngineResult documentView) 7: { 8: this.bodyView = bodyView; 9: this.documentView = documentView; 10: } 11:   12: public void Render(ViewContext viewContext, System.IO.TextWriter writer) 13: { 14: ChromeViewContext chromeViewContext = ChromeViewContext.From(viewContext); 15:   16: // First render the Body view to the BodyContent 17: using (var bodyViewWriter = new StringWriter()) 18: { 19: var bodyViewContext = new ViewContext(viewContext, bodyView.View, viewContext.ViewData, viewContext.TempData, bodyViewWriter); 20: this.bodyView.View.Render(bodyViewContext, bodyViewWriter); 21: chromeViewContext.BodyContent = bodyViewWriter.ToString(); 22: } 23: // Now render the Document view 24: this.documentView.View.Render(viewContext, writer); 25: } 26: } The ChromeViewContext (code excluded here) mainly just has a string property for the “BodyContent” – but it also makes sure to put itself in the HttpContext so it’s available. Finally, we created a little extension method so the module’s view can be rendered in the appropriate place: 1: public static void RenderBody(this HtmlHelper htmlHelper) 2: { 3: ChromeViewContext chromeViewContext = ChromeViewContext.From(htmlHelper.ViewContext); 4: htmlHelper.ViewContext.Writer.Write(chromeViewContext.BodyContent); 5: } At this point, the other thing left is to decide how we want to implement the Chrome.aspx page. One approach is the copy/paste the HTML from the typical Site.Master and change the main content placeholder to use the HTML helper above – this way, there are no MasterPages anywhere. Alternatively, we could even have Chrome.aspx utilize the MasterPage if we wanted (e.g., in the case where some pages are Chromed and some pages want to use traditional MasterPage): 1: <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 2: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 3: <% Html.RenderBody(); %> 4: </asp:Content> At this point, it’s all academic. I can create a controller like this: 1: [Chromed] 2: public class WidgetController : Controller 3: { 4: public ActionResult Index() 5: { 6: return View(); 7: } 8: } Then I’ll just create Index.ascx (a partial view) and put in the text “Inside my widget”. Now when I run the app, I can request the full route (notice the controller name of “widget” in the address bar below) and the HTML from my Index.ascx will just appear where it is supposed to.   This means no more warnings for missing MasterPages and no more need for your module to have knowledge of the host’s MasterPage placeholders. You have the option of using the Chrome.aspx in the host or providing your own while embedding it as an embedded resource itself. I’m curious to know what people think of this approach. The code above was done with my own local copy of MvcContrib so it’s not currently something you can download. At this point, these are just my initial thoughts – just incorporating some ideas for Orchard into non-Orchard apps to enable building modular/composite apps more easily. Additionally, on the flip side, I still believe that Portable Areas have potential as the module packaging story for Orchard itself.   What do you think?

    Read the article

  • Adding a UserControl within another UserControl in Sharepoint 2007

    - by DougJones
    I am using WSPBuilder to create and deploy my web part from a user control, as shown here. This works perfectly well, but I have added another user control to the project. I am adding it in page_init by going the Page.LoadControl("~/_controltemplates/MyControl.ascx"); route. It builds successfully, but after adding it to the page, I get The referenced file '/MyControl.ascx' is not allowed on this page. This control is in the ControlTemplates folder in the hive. In the web.config for this sharepoint 2007 site, all items within _controltemplates are listed as safe, as shown here <SafeControl Src="~/_controltemplates/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" /> How do I get the ascx file to be allowed on the page and get this webpart to display successfully?

    Read the article

  • Rendering a derived partial view with Html.RenderPartial

    - by FreshCode
    Calling Html.RenderPartial("~/Views/Payments/MyControl.ascx"); from a view works if Method.ascx is a control that directly inherits System.Web.Mvc.ViewUserControl. However, if the control inherits a new class that derives from System.Web.Mvc.ViewUserControl, the call to Html.RenderPartial("~/Views/Payments/MyDerivedControl.ascx"); fails, reporting that no such view exists. Example derived ViewUserControl: class MyDerivedControl : System.Web.Mvc.ViewUserControl { public Method() { ViewData["SomeData"] = "test"; } } Is there a workaround, or is there another way I should be doing this? Perhaps an HTML helper?

    Read the article

  • ASP.NET MVC - Views location Problem : The view 'Index' or its master was not found

    - by user326873
    Hi all, I've create an asp.net MVC 2 project, it works fine!! I've been asked to integrate the project in an existing web project in classic asp.net (I've add the folder containing the source, and not make a new project, because they have to bee in same project) I've configured my web.config file <pages pageBaseType="System.Web.UI.Page" > <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </controls> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Linq" /> <add namespace="System.Collections.Generic" /> <add namespace="SearchApp.Helpers.CheckBoxList"/> <add namespace="SearchApp.Helpers.Pager"/> </namespaces> </pages> <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </httpModules> <!--- END MVC config section--> and my global.asax file (I'm working under IIS 5.1) : public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "SearchApp", // Route name "SearchApp/{controller}.aspx/{action}/{id}", // URL with parameters new { controller = "Search", action = "Index", id = "" } // Parameter defaults ); } protected void Application_Start(Object sender, EventArgs e) { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); } The hierarchy of the project is (I can’t find how to insert Image in the post): +Project ++MVC2AppFolder +++Controller ++++SearchController.cs +++Views ++++Search +++++Index.aspx ++global.asax ++web.config as you can see the global.asax is not in the MVC App folder when I try to access the page Search/index.aspx using this url http://localhost/cstfwsrv/SearchApp/Search.aspx/Index[^] have the following error : I The view 'Index' or its master was not found. The following locations were searched: ~/Views/Search/Index.aspx ~/Views/Search/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: The view 'Index' or its master was not found. The following locations were searched: ~/Views/Search/Index.aspx ~/Views/Search/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: The view 'Index' or its master was not found. The following locations were searched: ~/Views/Search/Index.aspx ~/Views/Search/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx] System.Web.Mvc.ViewResult.FindView(ControllerContext context) +253553 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +139 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +10 System.Web.Mvc.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11() +20 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +251 System.Web.Mvc.<>c__DisplayClass16.<InvokeActionResultWithFilters>b__13() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +178 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 As you can see he search for the Index.aspx page under ~/Views/Search/Index.aspx , wich is under ~/MVC2AppFolder/Views/Search/Index.aspx Is there a way to set in the Route Method, or any where else, the View Path? Thanks’ in advance

    Read the article

  • ASP User Control Issue

    - by Steven
    I am attempting to construct my own date picker using code from several sources. Why won't the calendar hide when visible? myDate.ascx <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="myDate.ascx.vb" Inherits="Website.myDate" %> <asp:TextBox ID="dateText" runat="server" > </asp:TextBox> <asp:Button ID="dateBtn" runat="server" UseSubmitBehavior="false" Text="x" /> <asp:Calendar ID="dateCal" runat="server" ></asp:Calendar> myDate.ascx.vb Partial Public Class myDate Inherits System.Web.UI.UserControl Protected Sub dateCal_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dateCal.SelectionChanged dateText.Text = dateCal.SelectedDate ' Update text box' dateCal.Visible = False ' Hide calendar' End Sub Protected Sub dateCal_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles dateCal.VisibleMonthChanged dateCal.Visible = True ' For some reason, changing the month hides the calendar (so show it)' End Sub Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dateCal.Visible = False ' Hide calendar on load' End Sub Protected Sub dateBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles dateBtn.Click dateCal.Visible = Not dateCal.Visible ' On button press, toggle visibility' End Sub End Class

    Read the article

  • how to display using asp.net mvc

    - by kumar
    I have a partial view called StudentInfo.ascx. In it I have something like this: <fieldset> <legend>Students Information</legend> <div> <label>First Name:</label> <label>Last Name:</label> </div> </fieldset> I have another partial view called Detail.ascx which will need to display this StudentInfo.ascx. I did something like this: <%= Html.RenderAction("StudentInfo"); %> Is that right?

    Read the article

  • A Custom View Engine with Dynamic View Location

    - by imran_ku07
        Introduction:          One of the nice feature of ASP.NET MVC framework is its pluggability. This means you can completely replace the default view engine(s) with a custom one. One of the reason for using a custom view engine is to change the default views location and sometimes you need to change the views location at run-time. For doing this, you can extend the default view engine(s) and then change the default views location variables at run-time.  But, you cannot directly change the default views location variables at run-time because they are static and shared among all requests. In this article, I will show you how you can dynamically change the views location without changing the default views location variables at run-time.       Description:           Let's say you need to synchronize the views location with controller name and controller namespace. So, instead of searching to the default views location(Views/ControllerName/ViewName) to locate views, this(these) custom view engine(s) will search in the Views/ControllerNameSpace/ControllerName/ViewName folder to locate views.           First of all create a sample ASP.NET MVC 3 application and then add these custom view engines to your application,   public class MyRazorViewEngine : RazorViewEngine { public MyRazorViewEngine() : base() { AreaViewLocationFormats = new[] { "~/Areas/{2}/Views/%1/{1}/{0}.cshtml", "~/Areas/{2}/Views/%1/{1}/{0}.vbhtml", "~/Areas/{2}/Views/%1/Shared/{0}.cshtml", "~/Areas/{2}/Views/%1/Shared/{0}.vbhtml" }; AreaMasterLocationFormats = new[] { "~/Areas/{2}/Views/%1/{1}/{0}.cshtml", "~/Areas/{2}/Views/%1/{1}/{0}.vbhtml", "~/Areas/{2}/Views/%1/Shared/{0}.cshtml", "~/Areas/{2}/Views/%1/Shared/{0}.vbhtml" }; AreaPartialViewLocationFormats = new[] { "~/Areas/{2}/Views/%1/{1}/{0}.cshtml", "~/Areas/{2}/Views/%1/{1}/{0}.vbhtml", "~/Areas/{2}/Views/%1/Shared/{0}.cshtml", "~/Areas/{2}/Views/%1/Shared/{0}.vbhtml" }; ViewLocationFormats = new[] { "~/Views/%1/{1}/{0}.cshtml", "~/Views/%1/{1}/{0}.vbhtml", "~/Views/%1/Shared/{0}.cshtml", "~/Views/%1/Shared/{0}.vbhtml" }; MasterLocationFormats = new[] { "~/Views/%1/{1}/{0}.cshtml", "~/Views/%1/{1}/{0}.vbhtml", "~/Views/%1/Shared/{0}.cshtml", "~/Views/%1/Shared/{0}.vbhtml" }; PartialViewLocationFormats = new[] { "~/Views/%1/{1}/{0}.cshtml", "~/Views/%1/{1}/{0}.vbhtml", "~/Views/%1/Shared/{0}.cshtml", "~/Views/%1/Shared/{0}.vbhtml" }; } protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) { var nameSpace = controllerContext.Controller.GetType().Namespace; return base.CreatePartialView(controllerContext, partialPath.Replace("%1", nameSpace)); } protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) { var nameSpace = controllerContext.Controller.GetType().Namespace; return base.CreateView(controllerContext, viewPath.Replace("%1", nameSpace), masterPath.Replace("%1", nameSpace)); } protected override bool FileExists(ControllerContext controllerContext, string virtualPath) { var nameSpace = controllerContext.Controller.GetType().Namespace; return base.FileExists(controllerContext, virtualPath.Replace("%1", nameSpace)); } } public class MyWebFormViewEngine : WebFormViewEngine { public MyWebFormViewEngine() : base() { MasterLocationFormats = new[] { "~/Views/%1/{1}/{0}.master", "~/Views/%1/Shared/{0}.master" }; AreaMasterLocationFormats = new[] { "~/Areas/{2}/Views/%1/{1}/{0}.master", "~/Areas/{2}/Views/%1/Shared/{0}.master", }; ViewLocationFormats = new[] { "~/Views/%1/{1}/{0}.aspx", "~/Views/%1/{1}/{0}.ascx", "~/Views/%1/Shared/{0}.aspx", "~/Views/%1/Shared/{0}.ascx" }; AreaViewLocationFormats = new[] { "~/Areas/{2}/Views/%1/{1}/{0}.aspx", "~/Areas/{2}/Views/%1/{1}/{0}.ascx", "~/Areas/{2}/Views/%1/Shared/{0}.aspx", "~/Areas/{2}/Views/%1/Shared/{0}.ascx", }; PartialViewLocationFormats = ViewLocationFormats; AreaPartialViewLocationFormats = AreaViewLocationFormats; } protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) { var nameSpace = controllerContext.Controller.GetType().Namespace; return base.CreatePartialView(controllerContext, partialPath.Replace("%1", nameSpace)); } protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) { var nameSpace = controllerContext.Controller.GetType().Namespace; return base.CreateView(controllerContext, viewPath.Replace("%1", nameSpace), masterPath.Replace("%1", nameSpace)); } protected override bool FileExists(ControllerContext controllerContext, string virtualPath) { var nameSpace = controllerContext.Controller.GetType().Namespace; return base.FileExists(controllerContext, virtualPath.Replace("%1", nameSpace)); } }             Here, I am extending the RazorViewEngine and WebFormViewEngine class and then appending /%1 in each views location variable, so that we can replace /%1 at run-time. I am also overriding the FileExists, CreateView and CreatePartialView methods. In each of these method implementation, I am replacing /%1 with controller namespace. Now, just register these view engines in Application_Start method in Global.asax.cs file,   protected void Application_Start() { ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new MyRazorViewEngine()); ViewEngines.Engines.Add(new MyWebFormViewEngine()); ................................................ ................................................ }             Now just create a controller and put this controller's view inside Views/ControllerNameSpace/ControllerName folder and then run this application. You will find that everything works just fine.       Summary:          ASP.NET MVC uses convention over configuration to locate views. For many applications this convention to locate views is acceptable. But sometimes you may need to locate views at run-time. In this article, I showed you how you can dynamically locate your views by using a custom view engine. I am also attaching a sample application. Hopefully you will enjoy this article too. SyntaxHighlighter.all()  

    Read the article

  • multi-clients web application,should I use custom user controls or a common user control

    - by ValidfroM
    Say my company is going to build a complicated asp.net web form education system. One of the module is web based registration. To make it flexiable, we decide to use user control(ascx) with rule-engine (work flow) regulating all business logic behide them. Thus in future,for different clients, we can simply config basic existing rules or adding new rules.(Rules stored in db or XML per client). Now the question is how to deal with the user controls (ascx)? My opinion is for different client build diffrent user control from scratch. other voice is like reuse existing user controls.

    Read the article

  • Is this the correct way to implement .NET MVC website structure?

    - by aspdotnetuser
    I have recently seen a .NET MVC solution in which the markup in the .aspx views have a Controller as their model, and the .ascx user controls they contain use a separate model. I'm new to MVC and I wanted to find out about a few things I'm not clear on. An example of how the code is implemented: UserDetails.aspx view has markup that shows it's using the UserDetailsController.cs as the model. It contains RenderPartial("User_Details.ascx", UserDetailsModel) and passes it the UserDetailsModel. Is this the standard/correct way of implementing MVC? Or just one way to implement it? I also noticed that the classes used as Models appear to be Service classes that have [DataMember] and [DataContract] attributes on the class name and properties - what is the advantage of this implementation?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >