Search Results

Search found 36254 results on 1451 pages for 'asp free'.

Page 15/1451 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Asp.net mvc json

    - by user310657
    Hi, I am working on a mvc project, and having problem with json. i have created a demo project with list of colors public JsonResult GetResult() { List strList = new List(); strList.Add("white"); strList.Add("blue"); strList.Add("black"); strList.Add("red"); strList.Add("orange"); strList.Add("green"); return this.Json(strList); } i am able to get these on my page, but when i try to delete one color, that is when i send the following using jquery function deleteItem(item) { $.ajax({ type: "POST", url: "/Home/Delete/white", data: "{}", contentType: "application/json; charset=utf-8", success: ajaxCallSucceed, dataType: "json", failure: ajaxCallFailed }); } the controler action public JsonResult Delete(string Color) {} Color always returns null, even if i have specified "/Home/Delete/white" in the url. i know i am doing something wrong or missing something, but not able to find out what. please can any one guide me in the right direction.

    Read the article

  • Asp.net: Replace GenericPrincipal

    - by Pickels
    Hello, I was wondering what the best way is to replace the genericPrincipal with my own CustomGenericPrincipal. At the moment I have something like this but I aint sure if it's correct. protected void Application_AuthenticateRequest(Object sender, EventArgs e) { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); var identity = new CustomIdentity(authTicket); var principal = new CustomPrincipal(identity); Context.User = principal; } else { //Todo: check if this is correct var genericIdentity = new CustomGenericIdentity(); Context.User = new CustomPrincipal(genericIdentity); } } I need to replace it because I need a Principal that implements my ICustomPrincipal interface because I am doing the following with Ninject: Bind<ICustomPrincipal>().ToMethod(x => (ICustomPrincipal)HttpContext.Current.User) .InRequestScope(); So what's the best way to replace the GenericPrincipal? Thanks in advance, Pickels

    Read the article

  • remove dead routes in asp.net mvc 2

    - by loviji
    hello, i have get a problem. The request for 'Account' has found the following matching controllers: uqs.Controllers.Admin.AccountController MvcApplication1.Controllers.AccountController I search in project by Visual Studio MvcApplication1.Controllers.AccountController to remove it. but can't find match. So, I try to register a route: routes.MapRoute( "LogAccount", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "AccountController", action = "LogOn", id = "" }, new string[] { "uqs.Controllers.Admin" } // Parameter defaults ); But can't solve problem. Multiple types were found that match the controller named 'Account'. How I can Remove MvcApplication1.Controllers.AccountController. or fix this problem? Thanks.

    Read the article

  • Site Security/Access management for asp.net mvc application

    - by minal
    I am trying to find a good pattern to use for user access validation. Basically on a webforms application I had a framework which used user roles to define access, ie, users were assigned into roles, and "pages" were granted access to a page. I had a table in the database with all the pages listed in it. Pages could have child pages that got their access inherited from the parent. When defining access, I assigned the roles access to the pages. Users in the role then had access to the pages. It is fairly simple to manage as well. The way I implemented this was on a base class that every page inherited. On pageload/init I would check the page url and validate access and act appropriately. However I am now working on a MVC application and need to implement something similar, however I can't find a good way to make my previous solution work. Purely because I don't have static pages as url paths. Also I am not sure how best to approach this as I now have controllers rather then aspx pages. I have looked at the MVCSitemapprovider, but that does not work off a database, it needs a sitemap file. I need control of changing user persmissions on the fly. Any thoughts/suggestions/pointers would be greatly appreciated.

    Read the article

  • Validation firing in ASP.NET MVC

    - by rkrauter
    I am lost on this MVC project I am working on. I also read Brad Wilsons article. http://bradwilson.typepad.com/blog/2010/01/input-validation-vs-model-validation-in-aspnet-mvc.html I have this: public class Employee { [Required] public int ID { get; set; } [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } } and these in a controller: public ActionResult Edit(int id) { var emp = GetEmployee(); return View(emp); } [HttpPost] public ActionResult Edit(int id, Employee empBack) { var emp = GetEmployee(); if (TryUpdateModel(emp,new string[] { "LastName"})) { Response.Write("success"); } return View(emp); } public Employee GetEmployee() { return new Employee { FirstName = "Tom", LastName = "Jim", ID = 3 }; } and my view has the following: <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary() %> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%= Html.LabelFor(model => model.FirstName) %> </div> <div class="editor-field"> <%= Html.DisplayFor(model => model.FirstName) %> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.LastName) %> </div> <div class="editor-field"> <%= Html.TextBoxOrLabelFor(model => model.LastName, true)%> <%= Html.ValidationMessageFor(model => model.LastName) %> </div> <p> <input type="submit" value="Save" /> </p> </fieldset> <% } %> Note that the only field editable is the LastName. When I postback, I get back the original employee and try to update it with only the LastName property. But but I see on the page is the following error: •The FirstName field is required. This from what I understand, is because the TryUpdateModel failed. But why? I told it to update only the LastName property. I am using MVC2 RTM Thanks in advance.

    Read the article

  • Calling ASP.NET MVC Controller explicitly via AJAX

    - by effkay
    I know that I can use following piece of code to refresh a div: <%=Ajax.ActionLink( "Update", "Administration", new AjaxOptions { UpdateTargetId = "grid", LoadingElementId = "grid-wait" } ) %> But this creates a link; user will have to click on it to get the view refreshed. How can I make it automatic, i.e., like say if I want the grid to be refreshed after every five seconds?

    Read the article

  • Ajax comments form in ASP.NET MVC2, howto?

    - by Artiom Chilaru
    I've been playing around with different aspects of MVC for some time now, and I've reached a situation where I'm not sure what would be the best way to solve a problem. I'm hoping that the SO community will help me out here :P I've seen a number of examples of Ajax.BeginForm on the internet, and it seems like a very nifty idea. E.g. you have a dropdown where you select a customer - and on selecting one it will load this client's details in some placeholder on the page. This works perfectly fine. But what to do if you want to tie in some validation in the box? Just hypothetically, imagine an article page, and user comments in the bottom. Below the comments area there's an ajax-y "Add comment" box. When a user adds a comment, it will appear in the comments area, below the last comment there. If I set the Ajax.BeginForm to Append the result of the call to the Comments area, it will work fine. But what if the data posted is not valid? Instead of appending a "successful" comment to the comments area I have to show the user validation errors. At this point I decided that the area INSIDE the Ajax.BeginForm will be inside a partial, and the form's submits will return this partial. Validation works fine. On each submit we reload the contents inside the form element. But how to add the successful comment to the top? Other things to consider: The comment form also has a "Preview" button. When the user clicks on Preview, I should load the rendered comment into a preview box. This will probably be inside the form area as well. I was thinking of using Json results instead. When the user submits the form, the server code will generate a Json object with a Success value, and html rendered partials as some properties. Something like { "success": true, "form": "<html form data>", "comment": "successful comment html to inject into the page" } This would be a perfect solution, except there's no way in MVC to render a partial into a string, inside the controller (separation of context, remember?). So.. what should I do then? Any "correct" way to implement this? Anyone???

    Read the article

  • How to use ASP .NET dropdown with ajax

    - by Poomjai
    Greeting, I'm beginer of ajax technology and now i need to create two dropdown in MVC project for example: First dropdown has the list of classroom [601,602,603] when i choose one then next dropdown will has the list of student belong to each class room. Now, I already create the repository class that has method GetStudentByClassroomName() and already connect to the database. Can anyone give me a suggestion how to create it or any technology to create the dropdown like this? Thank you very much ^_^

    Read the article

  • How do I insert data using a DetailsView into an access database without everything breaking?

    - by Steve
    Hey I'm getting the error: Data type mismatch in criteria expression. when I try to submit a DetailsView insert. Code for Default.aspx: (from inside an asp:Content tag) <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="user_id" DataSourceID="AccessDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <Fields> <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" /> <asp:BoundField DataField="password" HeaderText="password" SortExpression="password" /> <asp:BoundField DataField="users_name" HeaderText="users_name" SortExpression="users_name" /> <asp:BoundField DataField="image_path" HeaderText="image_path" SortExpression="image_path" /> <asp:BoundField DataField="mobile" HeaderText="mobile" SortExpression="mobile" /> <asp:BoundField DataField="twitter" HeaderText="twitter" SortExpression="twitter" /> <asp:TemplateField HeaderText="privacy_level_id" SortExpression="privacy_level_id"> <InsertItemTemplate> <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="AccessDataSource2" DataTextField="privacy_level_name" DataValueField="privacy_level_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [PrivacyLevels]"></asp:AccessDataSource> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("date_of_birth") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="course_id" SortExpression="course_id"> <EditItemTemplate> <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="AccessDataSource3" DataTextField="course_name" DataValueField="course_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource3" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Courses]"> </asp:AccessDataSource> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DropDownList22" runat="server" DataSourceID="AccessDataSource22" DataTextField="privacy_level_name" DataValueField="privacy_level_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource22" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [PrivacyLevels]"></asp:AccessDataSource> </InsertItemTemplate> <ItemTemplate> <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="AccessDataSource3" DataTextField="course_name" DataValueField="course_id" Enabled="False"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource3" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Courses]"></asp:AccessDataSource> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="nationality_id" SortExpression="nationality_id"> <EditItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource20" DataTextField="nationality_name" DataValueField="nationality_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource20" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Nationalities]"> </asp:AccessDataSource> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource20" DataTextField="nationality_name" DataValueField="nationality_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource20" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Nationalities]"> </asp:AccessDataSource> </InsertItemTemplate> <ItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource20" DataTextField="nationality_name" DataValueField="nationality_id" Enabled="False"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource20" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Nationalities]"> </asp:AccessDataSource> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="residence_id" SortExpression="residence_id"> <EditItemTemplate> <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="AccessDataSource4" DataTextField="residence_name" DataValueField="residence_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource4" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Residences]"></asp:AccessDataSource> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="AccessDataSource4" DataTextField="residence_name" DataValueField="residence_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource4" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Residences]"></asp:AccessDataSource> </InsertItemTemplate> <ItemTemplate> <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="AccessDataSource4" DataTextField="residence_name" DataValueField="residence_id" Enabled="False"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource4" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Residences]"></asp:AccessDataSource> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="course_year" HeaderText="course_year" SortExpression="course_year" /> <asp:TemplateField HeaderText="gender_id" SortExpression="gender_id"> <EditItemTemplate> <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="AccessDataSource5" DataTextField="gender_name" DataValueField="gender_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource5" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Genders]"></asp:AccessDataSource> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="AccessDataSource5" DataTextField="gender_name" DataValueField="gender_id"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource5" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Genders]"></asp:AccessDataSource> </InsertItemTemplate> <ItemTemplate> <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="AccessDataSource5" DataTextField="gender_name" DataValueField="gender_id" Enabled="False"> </asp:DropDownList> <asp:AccessDataSource ID="AccessDataSource5" runat="server" DataFile="~/App_Data/VisageFinal.mdb" SelectCommand="SELECT * FROM [Genders]"></asp:AccessDataSource> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowInsertButton="True" InsertText="Create my user!" /> </Fields> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:DetailsView> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/VisageFinal.mdb" DeleteCommand="DELETE FROM [Users] WHERE [user_id] = ?" InsertCommand="INSERT INTO [Users] ([email], [password], [users_name], [image_path], [mobile], [twitter], [privacy_level_id], [nationality_id], [course_id], [residence_id], [course_year], [gender_id]) VALUES ('?', '?', '?', '?', '?', '?', ?, ?, ?, ?, ?, ?)" SelectCommand="SELECT * FROM [Users]" UpdateCommand="UPDATE [Users] SET [email] = ?, [password] = ?, [users_name] = ?, [date_of_birth] = ?, [image_path] = ?, [mobile] = ?, [twitter] = ?, [privacy_level_id] = ?, [nationality_id] = ?, [course_id] = ?, [residence_id] = ?, [has_set_privacy_level] = ?, [course_year] = ?, [gender_id] = ? WHERE [user_id] = ?"> <DeleteParameters> <asp:Parameter Name="user_id" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="email" Type="String" /> <asp:Parameter Name="password" Type="String" /> <asp:Parameter Name="users_name" Type="String" /> <asp:Parameter Name="image_path" Type="String" /> <asp:Parameter Name="mobile" Type="String" /> <asp:Parameter Name="twitter" Type="String" /> <asp:Parameter Name="privacy_level_id" Type="Int32" /> <asp:Parameter Name="nationality_id" Type="Int32" /> <asp:Parameter Name="course_id" Type="Int32" /> <asp:Parameter Name="residence_id" Type="Int32" /> <asp:Parameter Name="has_set_privacy_level" Type="Boolean" /> <asp:Parameter Name="course_year" Type="Int32" /> <asp:Parameter Name="gender_id" Type="Int32" /> <asp:Parameter Name="user_id" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="email" Type="String" /> <asp:Parameter Name="password" Type="String" /> <asp:Parameter Name="users_name" Type="String" /> <asp:Parameter Name="image_path" Type="String" /> <asp:Parameter Name="mobile" Type="String" /> <asp:Parameter Name="twitter" Type="String" /> <asp:Parameter Name="privacy_level_id" Type="Int32" /> <asp:Parameter Name="nationality_id" Type="Int32" /> <asp:Parameter Name="course_id" Type="Int32" /> <asp:Parameter Name="residence_id" Type="Int32" /> <asp:Parameter Name="course_year" Type="Int32" /> <asp:Parameter Name="gender_id" Type="Int32" /> </InsertParameters> </asp:AccessDataSource> Any ideas what I've broken?

    Read the article

  • Asp.Net MVC ActionLink

    - by Pino
    Can anyone explain why the following happens? And how to resolve, Visual Studio 2010 and MVC2 <%= Html.ActionLink("Add New Option", "AddOption", "Product", new { @class = "lighbox" }, null)%> Results in /Product/AddOption?class=lightbox <%= Html.ActionLink("Add New Option", "AddOption", "Product", new { @class = "lighbox" })%> Results in /Product/AddOption?Length=7 Thanks

    Read the article

  • Working with images in asp.net MVC ViewMasterPage in design mode

    - by amit.codename13
    While designing a master page i am adding a number of images to it. I have an image tag inside the master page, <img src="../../Content/Images/img19.jpg" class="profileImage" /> When i run my app, the image doesn't show up in the browser because the src path in the page that browser gets is same as in the master page. ie. "../../Content/Images/img19.jpg" But it should have been "Content/Images/img19.jpg" If i correct the src path in master page as <img src="Content/Images/img19.jpg" class="profileImage" /> Then I can see the image in the browser but not in design mode. Any help is appreciated.

    Read the article

  • asp.net mvc making delete usercontrol information passing on and off

    - by mazhar kaunain baig
    i am creating a generalize deleteusercontrol , my aim is that on the listing page where all the records are listed when the delete is pressed i want to display the acknowledgment on the same page up the list. I had little idea to do that q1) first of all where will i place my deleteusercontrol(in the shared folder?). q2) on and off the deleteusercontrol as the acknowledgment will not be there all the time how would i be doing that on delete press. i don't want to pass any data in the querystring. q3)how would i be passing the records list id and listname to the general deleteusercontrol as it would be same for all the listing

    Read the article

  • client side validation in ascx files (user controls) for asp.net mvc

    - by Sefer KILIÇ
    hi, I have a logOn forn in ascx files and I render it as partial. How I can add a clinet side validation to this form, have any idea ? My below code does not work <%= Html.ValidationSummary(true, "Giris basarisiz oldu. Lütfen hatalari düzeltip tekrar deneyin.") %> <% Html.EnableClientValidation(); %> <% using (Html.BeginForm("LogOnProcess", "Account")) { %> <div> <fieldset> <legend>Hesap Bilgileri</legend> <div class="editor-label"> <%= Html.LabelFor(m => m.UserName) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(m => m.UserName) %> <%= Html.ValidationMessageFor(m => m.UserName) %> </div> <div class="editor-label"> <%= Html.LabelFor(m => m.Password) %> </div> <div class="editor-field"> <%= Html.PasswordFor(m => m.Password) %> <%= Html.ValidationMessageFor(m => m.Password) %> </div> <div class="editor-label"> <%= Html.CheckBoxFor(m => m.RememberMe) %> <%= Html.LabelFor(m => m.RememberMe) %> </div> <p> <input type="submit" value="Giris" /> </p> </fieldset> </div> <% } %>

    Read the article

  • A potentially dangerous Request.Form value in MVC 2 & ASP.NET 4.0

    - by Veton
    When I trying to send form containing value with xml, I get HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client All approaches I found: <%@ Page ValidateRequest="false" %> in .aspx-file. <pages validateRequest="false" /> in web.config. [ValidateInput(false)] on controller's action. don't help me. Hope for any advice.

    Read the article

  • Asp.net mvc, entity framework, Poco - Architecture

    - by user1576228
    I have a "small" enterprise application, aspnet mvc 3 + entity framework with POCO entity and repository pattern. I structured the solution in 4 projects: POCO entities Domain model Services web application When the application performs a query on the database, use one of the services provided, the service uses the repository and the small classes, as a result I have some dynamic proxy objects that I would like to convert in my domain entities, before using them in mvc views, but I do not know how. Dovrebber be set as the translator? This approach is reasonable?

    Read the article

  • RavenDB Ids and ASP.NET MVC3 Routes

    - by goober
    Hey all, Just building a quick, simple site with MVC 3 RC2 and RavenDB to test some things out. I've been able to make a bunch of projects, but I'm curious as to how Html.ActionLink() handles a raven DB ID. My example: I have a Document called "reasons" (a reason for something, just text mostly), which has reason text and a list of links. I can add, remove, and do everything else fine via my repository. Below is the part of my razor view that lists each reason in a bulleted list, with an Edit link as the first text: @foreach(var Reason in ViewBag.ReasonsList) { <li>@Html.ActionLink("Edit", "Reasons", "Edit", new { id = Reason.Id }, null) @Reason.ReasonText</li> <ul> @foreach (var reasonlink in Reason.ReasonLinks) { <li><a href="@reasonlink.URL">@reasonlink.URL</a></li> } </ul> } The Problem This works fine, except for the edit link. While the values and code here appear to work directly (i.e the link is firing directly), RavenDB saves my document's ID as "reasons/1". So, when the URL happens and it passes the ID, the resulting route is "http://localhost:4976/Reasons/Edit/reasons/2". So, the ID is appended correctly, but MVC is interpreting it as its own route. Any suggestions on how I might be able to get around this? Do I need to create a special route to handle it or is there something else I can do?

    Read the article

  • ASP.NET MVC Catch All

    - by rkrauter
    The ignore route is defined like this: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); Why not routes.IgnoreRoute("{resource}.axd/{*}"); What is the significance of pathInfo? Thanks.

    Read the article

  • Implementing a normal website inside ASP.NET MVC 2

    - by cc0
    I have a website consisting of an index.html, a number of style sheet files as well as some javascript files. Then I needed a way for this site to communicate efficiently with a Microsoft SQL Server, so I was recommended to use the MVC framework to facilitate that kind of communication. I created the C#.net controller code needed to output the necessary information from the database using URL parameters, so now I am trying to put the whole web-site together inside the MVC framework. I started an empty project-template in MVC 2 framework. I'm sure there must be a good way to implement the current code into this framework, but I am very uncertain as to what the best approach to this would be. Could anyone point me in the right direction here? I'm not sure whether I need to change any of the current HTML, or exactly what to add to it. I'd love to see some kind of guide or tutorial, or just any advice I can get as I try to learn this. Any help is very much appreciated!

    Read the article

  • ASP.NET MVC - Alternative to Role Provider?

    - by ebb
    Hey there, I'm trying to avoid the use of the Role Provider and Membership Provider since its way too clumsy in my opinion, and therefore I'm trying to making my own "version" which is less clumsy and more manageable/flexible. Now is my question.. is there an alternative to the Role Provider which is decent? (I know that I can do custom Role provier, membership provider etc.) By more manageable/flexible I mean that I'm limited to use the Roles static class and not implement directly into my service layer which interact with the database context, instead I'm bound to use the Roles static class which has its own database context etc, also the table names is awful.. Thanks in advance.

    Read the article

  • Making id'less url in asp.net mvc razor

    - by Sushant
    I am working with URL routing , and have some issues. I want my url to be like this: www.domain.com/p/myproduct But I also want to be able to retrieve the ID of the product, without accessing the database. I thought about having a URL like: www.domain.com/p/myproduct/1 But if I could hide the ID it would be better. So, how do I do it the simplest way? Currently my Global.asax has the following route: routes.MapLocalizedRoute("Product", "p/{productId}/{SeName}", new { controller = "Catalog", action = "Product", SeName = UrlParameter.Optional }, new { productId = @"\d+" }, new[] { "Nop.Web.Controllers" });

    Read the article

  • How to publish an ASP.NET MVC application to a free host

    - by Lirik
    Hi, I'm using a free web host (0000free) which supports ASP.NET MVC, but it uses Mono. This is the first time I deploy an MVC application, so I'm a little confused as to where I need to deploy it. I have Visual Studio 2010 and I used its Publish Feature (i.e. right click on the project name and click publish) and I tried several things: Publish method: FTP to the root folder. Publish method: FTP to the publich_html folder. Publish method: File System to the root folder. Publish method: File System to the publich_html folder. Publish method: File System to a local directory on my computer and then FTP to root and also tried the public_html folder. I went into the cPanel (control panel) to try and see if ASP.NET has to be added/enabled for my web site, but I didn't see anything there. I can't browse to Index.aspx nor can I redirect to it from index.html (as suggested from other posts on the host forum), right now I have a link from index.html to Index.aspx but it's not working either (see http://www.mydevarmy.com) I've also tried renaming Index.aspx to Default.aspx, but that doesn't work either. The search utility of the forum of the host is somewhat weak, so I use google to search their forum: http://www.google.com/search?q=publish+asp.net+site%3A0000free.com%2Fforum%2F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a I've been reading Pro ASP.NET MVC Framework and they have a chapter about publishing, but it doesn't provide any specific information with respect to the location of publishing, this is all they say (and it's not very helpful in my case): Where Should I Put My Application? You can deploy your application to any folder on the server. When IIS first installs, it automatically creates a folder for a web site called Default Web Site at c:\Inetpub\wwwroot\, but you shouldn’t feel any obligation to put your application files there. It’s very common to host applications on a different physical drive from the operating system (e.g., in e:\websites\ example.com). It’s entirely up to you, and may be influenced by concerns such as how you plan to back up the server. Here is the exception I get when I try to view my Index.aspx page: Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1) Description: HTTP 500. Error processing request. Stack Trace: System.Configuration.ConfigurationErrorsException: Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1) at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00000] in <filename unknown>:0 at System.Configuration.ConfigurationSection.DoDeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in <filename unknown>:0 at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0 at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0 at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0 at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path) [0x00000] in <filename unknown>:0 at System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection (System.String sectionName) [0x00000] in <filename unknown>:0 at System.Web.Compilation.BuildManager.get_CompilationConfig () [0x00000] in <filename unknown>:0 at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00000] in <filename unknown>:0 at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0 at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in <filename unknown>:0 at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00000] in <filename unknown>:0

    Read the article

  • What do you miss from classic-asp days that is not available in asp.net ?

    - by this. __curious_geek
    Many of us have come from classic-asp background and eventually picked up asp.net for better. But I miss many features from classic-asp that are not available in asp.net. Like, I don't get complete control over the markup renderred to the client in asp.net wherein in classic-asp it was possible. What are those features you miss from your classic-asp days ? PS: This question is tribute to original classic-asp that once ruled the world.

    Read the article

  • Cleaner HTML Markup with ASP.NET 4 Web Forms - Client IDs (VS 2010 and .NET 4.0 Series)

    - by ScottGu
    This is the sixteenth in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release. Today’s post is the first of a few blog posts I’ll be doing that talk about some of the important changes we’ve made to make Web Forms in ASP.NET 4 generate clean, standards-compliant, CSS-friendly markup.  Today I’ll cover the work we are doing to provide better control over the “ID” attributes rendered by server controls to the client. [In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu] Clean, Standards-Based, CSS-Friendly Markup One of the common complaints developers have often had with ASP.NET Web Forms is that when using server controls they don’t have the ability to easily generate clean, CSS-friendly output and markup.  Some of the specific complaints with previous ASP.NET releases include: Auto-generated ID attributes within HTML make it hard to write JavaScript and style with CSS Use of tables instead of semantic markup for certain controls (in particular the asp:menu control) make styling ugly Some controls render inline style properties even if no style property on the control has been set ViewState can often be bigger than ideal ASP.NET 4 provides better support for building standards-compliant pages out of the box.  The built-in <asp:> server controls with ASP.NET 4 now generate cleaner markup and support CSS styling – and help address all of the above issues.  Markup Compatibility When Upgrading Existing ASP.NET Web Forms Applications A common question people often ask when hearing about the cleaner markup coming with ASP.NET 4 is “Great - but what about my existing applications?  Will these changes/improvements break things when I upgrade?” To help ensure that we don’t break assumptions around markup and styling with existing ASP.NET Web Forms applications, we’ve enabled a configuration flag – controlRenderingCompatbilityVersion – within web.config that let’s you decide if you want to use the new cleaner markup approach that is the default with new ASP.NET 4 applications, or for compatibility reasons render the same markup that previous versions of ASP.NET used:   When the controlRenderingCompatbilityVersion flag is set to “3.5” your application and server controls will by default render output using the same markup generation used with VS 2008 and .NET 3.5.  When the controlRenderingCompatbilityVersion flag is set to “4.0” your application and server controls will strictly adhere to the XHTML 1.1 specification, have cleaner client IDs, render with semantic correctness in mind, and have extraneous inline styles removed. This flag defaults to 4.0 for all new ASP.NET Web Forms applications built using ASP.NET 4. Any previous application that is upgraded using VS 2010 will have the controlRenderingCompatbilityVersion flag automatically set to 3.5 by the upgrade wizard to ensure backwards compatibility.  You can then optionally change it (either at the application level, or scope it within the web.config file to be on a per page or directory level) if you move your pages to use CSS and take advantage of the new markup rendering. Today’s Cleaner Markup Topic: Client IDs The ability to have clean, predictable, ID attributes on rendered HTML elements is something developers have long asked for with Web Forms (ID values like “ctl00_ContentPlaceholder1_ListView1_ctrl0_Label1” are not very popular).  Having control over the ID values rendered helps make it much easier to write client-side JavaScript against the output, makes it easier to style elements using CSS, and on large pages can help reduce the overall size of the markup generated. New ClientIDMode Property on Controls ASP.NET 4 supports a new ClientIDMode property on the Control base class.  The ClientIDMode property indicates how controls should generate client ID values when they render.  The ClientIDMode property supports four possible values: AutoID—Renders the output as in .NET 3.5 (auto-generated IDs which will still render prefixes like ctrl00 for compatibility) Predictable (Default)— Trims any “ctl00” ID string and if a list/container control concatenates child ids (example: id=”ParentControl_ChildControl”) Static—Hands over full ID naming control to the developer – whatever they set as the ID of the control is what is rendered (example: id=”JustMyId”) Inherit—Tells the control to defer to the naming behavior mode of the parent container control The ClientIDMode property can be set directly on individual controls (or within container controls – in which case the controls within them will by default inherit the setting): Or it can be specified at a page or usercontrol level (using the <%@ Page %> or <%@ Control %> directives) – in which case controls within the pages/usercontrols inherit the setting (and can optionally override it): Or it can be set within the web.config file of an application – in which case pages within the application inherit the setting (and can optionally override it): This gives you the flexibility to customize/override the naming behavior however you want. Example: Using the ClientIDMode property to control the IDs of Non-List Controls Let’s take a look at how we can use the new ClientIDMode property to control the rendering of “ID” elements within a page.  To help illustrate this we can create a simple page called “SingleControlExample.aspx” that is based on a master-page called “Site.Master”, and which has a single <asp:label> control with an ID of “Message” that is contained with an <asp:content> container control called “MainContent”: Within our code-behind we’ll then add some simple code like below to dynamically populate the Label’s Text property at runtime:   If we were running this application using ASP.NET 3.5 (or had our ASP.NET 4 application configured to run using 3.5 rendering or ClientIDMode=AutoID), then the generated markup sent down to the client would look like below: This ID is unique (which is good) – but rather ugly because of the “ct100” prefix (which is bad). Markup Rendering when using ASP.NET 4 and the ClientIDMode is set to “Predictable” With ASP.NET 4, server controls by default now render their ID’s using ClientIDMode=”Predictable”.  This helps ensure that ID values are still unique and don’t conflict on a page, but at the same time it makes the IDs less verbose and more predictable.  This means that the generated markup of our <asp:label> control above will by default now look like below with ASP.NET 4: Notice that the “ct100” prefix is gone. Because the “Message” control is embedded within a “MainContent” container control, by default it’s ID will be prefixed “MainContent_Message” to avoid potential collisions with other controls elsewhere within the page. Markup Rendering when using ASP.NET 4 and the ClientIDMode is set to “Static” Sometimes you don’t want your ID values to be nested hierarchically, though, and instead just want the ID rendered to be whatever value you set it as.  To enable this you can now use ClientIDMode=static, in which case the ID rendered will be exactly the same as what you set it on the server-side on your control.  This will cause the below markup to be rendered with ASP.NET 4: This option now gives you the ability to completely control the client ID values sent down by controls. Example: Using the ClientIDMode property to control the IDs of Data-Bound List Controls Data-bound list/grid controls have historically been the hardest to use/style when it comes to working with Web Form’s automatically generated IDs.  Let’s now take a look at a scenario where we’ll customize the ID’s rendered using a ListView control with ASP.NET 4. The code snippet below is an example of a ListView control that displays the contents of a data-bound collection — in this case, airports: We can then write code like below within our code-behind to dynamically databind a list of airports to the ListView above: At runtime this will then by default generate a <ul> list of airports like below.  Note that because the <ul> and <li> elements in the ListView’s template are not server controls, no IDs are rendered in our markup: Adding Client ID’s to Each Row Item Now, let’s say that we wanted to add client-ID’s to the output so that we can programmatically access each <li> via JavaScript.  We want these ID’s to be unique, predictable, and identifiable. A first approach would be to mark each <li> element within the template as being a server control (by giving it a runat=server attribute) and by giving each one an id of “airport”: By default ASP.NET 4 will now render clean IDs like below (no ctl001-like ids are rendered):   Using the ClientIDRowSuffix Property Our template above now generates unique ID’s for each <li> element – but if we are going to access them programmatically on the client using JavaScript we might want to instead have the ID’s contain the airport code within them to make them easier to reference.  The good news is that we can easily do this by taking advantage of the new ClientIDRowSuffix property on databound controls in ASP.NET 4 to better control the ID’s of our individual row elements. To do this, we’ll set the ClientIDRowSuffix property to “Code” on our ListView control.  This tells the ListView to use the databound “Code” property from our Airport class when generating the ID: And now instead of having row suffixes like “1”, “2”, and “3”, we’ll instead have the Airport.Code value embedded within the IDs (e.g: _CLE, _CAK, _PDX, etc): You can use this ClientIDRowSuffix approach with other databound controls like the GridView as well. It is useful anytime you want to program row elements on the client – and use clean/identified IDs to easily reference them from JavaScript code. Summary ASP.NET 4 enables you to generate much cleaner HTML markup from server controls and from within your Web Forms applications.  In today’s post I covered how you can now easily control the client ID values that are rendered by server controls.  In upcoming posts I’ll cover some of the other markup improvements that are also coming with the ASP.NET 4 release. Hope this helps, Scott

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >