Search Results

Search found 57033 results on 2282 pages for 'asp net mvc 2 metadata'.

Page 89/2282 | < Previous Page | 85 86 87 88 89 90 91 92 93 94 95 96  | Next Page >

  • asp.net MVC partial view

    - by DotnetSparrow
    Hi all: I have created a function for load event like this: $(function() { $('#dvGames').load( '<%= Url.Action("Partial3", "LiveGame") %>',{ gameDate: '2011-03-06' } ); }); and it works. Also, I have created a function for date change like this: $(function() { $('#datepicker').datepicker({ onSelect: function(dateText, inst) { $.ajax({ type: "POST", url: "/LiveGame/Partial3", data: "gameDate=" + dateText, success: function(result) { alert(result); var domElement = $(result); // create element from html $("#dvGames").append(domElement); // append to end of list } }); } }); }); but it doesnt work. neither it goes in controller action. My controller action is: public ActionResult Partial3(string gameDate) { return PartialView("Partial3"); } Please suggest me solution to this.

    Read the article

  • ASP.NET MVC: Routing

    - by JamesBrownIsDead
    Let's say I have this Controller: public class GlobalizationController : Controller { public JavaScriptResult GlobalizedLabels(string virtualPath) { return new JavaScriptResult(); } } I want the controller to handle (i.e. invoke from) any of the relative URLs below: /globalization/~Enlargement/Controls/Container.ascx /globalization/test/foobar.aspx /globalization/HappyTimes/Are/Right/Now What would my entry in global.asax routes.MapRoute() entry look like? As in... routes.MapRoute("Globalization", "globalization/{virtualPath}", new { controller = "Globalization", action = "GlobalizedLabels" }); The URL pattern "{virtualPath}" is wrong. What should it be?

    Read the article

  • Asp.Net MVC best way to update cached table

    - by Eddy Mishiyev
    There are certain tables that get called often but updated rarely. One of these tables is Departments. So to save DB trips, I think it is ok to cache this table taking into consideration that the table has very small size. However, once you cached it an issue of keeping the table data fresh occurs. So what is the best way to determine that the table is dirty and therefore requires a reload and how that code should be invoked. I look for solution that will be scalable. So updating the cache right after inserting will not work. So if one machine inserted the record all other on network should get notified to reload the cache. I was thinking for calling corresponding web service from T-SQL but don't really like the idea of consuming recourses on sql server. So what are the best practices to resolve this type of problems. Thanks in advance Eddy

    Read the article

  • ASP.NET MVC - Disable Html Helper control using boolean value from Model

    - by The Matt
    I am outputting a textbox to the page using the Html helpers. I want to add the disabled attribute dynamically based on whether or not a boolean value in my model is true or false. My model has a method that returns a boolean value: <% =Model.IsMyTextboxEnabled() %> I currently render the textbox like follows, but I want to now enabled or disable it: <% =Html.TextBox("MyTextbox", Model.MyValuenew { id = "MyTextbox", @class = "MyClass" })%> If the return value of Model.IsMyTextboxEnabled() == true I want the following to be output: <input class="MyClass" id="MyTextbox" name="MyTextbox" type="text" value="" /> If it == false, I want it to output as: <input class="MyClass" id="MyTextbox" name="MyTextbox" type="text" value="" disabled /> What is the cleanest way to do this?

    Read the article

  • asp.net mvc select change redirect to Action

    - by mazhar kaunain baig
    I am correctly passing the action name from the Controller to the paging class and then using select list i want to redirect to that action. at this moment it is appending to the current url.i want the correct way of redirecting to the controller action manageUser using select list below What should we have here in Model.COntroller . ControllerName/ActionName/ or Just ActionName <select id="paging" onchange="location.href='<%= Model.Controller %>'+this.value"> <% for (int i = 1; i <= Model.TotalPages; i++) { %> <option id=<%=i %>><%=i %></option> <% } %> </select> public class PaginatedList<T> : List<T> { public string Controller { get; private set; } public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize,string Cont) { Controller = Cont; // here is the controller } } Controller public ActionResult ManageUser(int? page) { const int pageSize = 5; var AllUser = UserRepository.GetAllUser(); var paginatedUsers = new PaginatedList<Users>(AllUser, page ?? 1, pageSize,"ManageUser/Page/"); return View(paginatedUsers); }

    Read the article

  • C#/ASP.NET MVC 4 Instantiate Object Derived From Interface In Factory Method

    - by Chris
    Currently have a Factory class that features a GetSelector function, which returns a concrete implementation of ISelector. I have several different classes that implement ISelector and based on a setting I would like to receive the appropriate ISelector back. public interface ISelector { string GetValue(string Params); } public class XmlSelector : ISelector { public string GetValue(string Params) { // open XML file and get value } } public static class SelectorFactory { public static ISelector GetSelector() { return new XmlSelector(); // Needs changing to look at settings } } My question is what is the best way to store the setting? I am aware of using AppSettings etc. but I'm not sure whether I want to have to store strings in the web.config and perform a switch on it - just seems to be really tightly coupled in that if a new implementation of ISelector is made, then the Factory would need to be changed. Is there any way of perhaps storing an assembly name and instantiating based on that? Thanks, Chris

    Read the article

  • HttpRequestValidationexception on Asp.Net MVC

    - by elranu
    I’m getting an HttpRequestValidationexception with this error message: “A potentially dangerous Request.Form value was detected from the client”. But I have AllowHtml on the property that I’m getting the error. The problem is that later in my code I’m getting the following property to know in witch format I will show my view ControllerContext.HttpContext.Request.Params.AllKeys.Contains("format"). And on this “Param Getter” I’m getting the error. Let’s say my code is similar to the following: public class House { [AllowHtml] public string Text { get; set; } public string Name { get; set; } } [HttpPost, ValidateAntiForgeryToken] public ActionResult CreateTopic(House h) { //business code if(ControllerContext.HttpContext.Request.Params.AllKeys.Contains("format")) { Return view; } } How can I solve this? I already try with the ValidateInput(false) attribute on the controller action method. Any idea?

    Read the article

  • Asp.Net MVC and Entity Framework Architecture

    - by Pino
    Hi, I'm working on a fairly large project at the moment and am currently in the planning stages. I've done a lot of reading into the various patterns suggested for development, somthing that has split the team at the moment is when using Entity Framework should the classes be passed through the applciation layers so that a view accepts an Entity Framework class or should these classes be mapped to BLL Classes and if so at which point (Controller or Library) should this be done? I'm interested in hearing some positives and negitives for each solutions.

    Read the article

  • visual studio recognizing .asp properly or suggestion for classic asp editor/iDE

    - by Neil Warner
    How do I get visual studio 2005 to work best with .asp files? I used to have this on my old PC but I can't get the settings right. I exported and important all my old settings and still no dice. alternatively I think there might be an even better choice for classic asp IDE editor. It'd be nice to have intellisense, completion, highlighting, stuff like that for ASP (vbscript) and css/html at the same time. (I'm happy not to type out css selectors) thanks

    Read the article

  • Problem with ASP.NET MVC DropDownList not displaying selected value

    - by Jova
    I have an aspx page which allows me to edit articles. Among things I can edit is which category the article belongs to. The category is chosen through a DropDownList as shown here, <%= Html.DropDownList("categoryID", (IEnumerable<SelectListItem>)ViewData["CategoryID"], new { @class = "textbox" }) %> However, the articles category isn't selected when I go to that page. The ViewData I use for the DropDownList looks like this, ViewData["CategoryID"] = new SelectList(categories, "CategoryID", "Title", article.CategoryID); Which should select the article.CategoryID as it's selected value. Have I done this wrong?

    Read the article

  • Problem Paging with Post Action in ASP.NET MVC

    - by Lukasz
    I have a page that takes a number of parameters on a form and posts them to an action. It returns a number of search results that need to be paged through. My pager uses ActionLink; <%= Html.ActionLink(i.ToString(), "Basic", new { page = (i - 1) })%> The results comeback as expected but when I click on page two it goes to the default Action, not the one marked with post. The form values do no get submitted again and the results that are shown for page two are the default results not filters with the parameters. I am not sure how to solve this problem? One way was to save the form values into the database on the post and reading them back on the default action but it seems overkill. Thank You!

    Read the article

  • Beginform is not working in Asp.net mvc control whenI am trying to send the values

    - by kumar
    Hello friends i have a beginform is soemthing like this, <% using (Html.BeginForm("edit", (Model.ExceptionCategoryID == "EXP") ? "expense" : "pricing", FormMethod.Post, new { @id="exc-" + Model.ExceptionID})) { %> <input type="hidden" id="Status" runat="server"/> <%= Html.ValidationSummary(true)%> input submit button <input id="bSubmit" type="submit" class="button" value="Save" /> <script type="text/javascript"> $(document).ready(function() { $('#bSubmit').click(function() { var Status = "<%=Model.ExceptionStatus.Trim()%>"; alert(Status); $('#1_Status').attr('value',Status); }); </script> on sbmit I am trying to send the Status value.. on controler var sta = Request.Form[0]; I am getting something like 3%24Status in the From key.. why its hapeening ? thanks

    Read the article

  • MVC Partial View Not Refreshing when using JSON data

    - by 40-Love
    I have a dropdown that I'm using to refresh a div with checkboxes. I am trying to figure out why my view is not refreshing if I pass in data in JSON format. If I pass in just a regular string, the view refreshes. If I pass in JSON data, the view does not refresh. If I step through the code in the Partial view, I can see the correct number of records are being passed in, however the view doesn't get refreshed with the correct number of checkboxes. I tried to add some cache directives, it didn't work. This doesn't work: $(function () { $('#ddlMoveToListNames').change(function () { var item = $(this).val(); var selectedListID = $('#ddlListNames').val(); var checkValues = $('input[name=c]:checked').map(function () { return $(this).val(); }).toArray(); $.ajax({ url: '@Url.Action("Test1", "WordList")', type: 'POST', cache: false, data: JSON.stringify({ words: checkValues, moveToListID: item, selectedListID: selectedListID }), dataType: 'json', contentType: 'application/json; charset=utf-8', success: function (result) { } }) .done(function (partialViewResult) { $("#divCheckBoxes").replaceWith(partialViewResult); }); }); }); This works: $(function () { $('#ddlMoveToListNames').change(function () { var item = $(this).val(); var selectedListID = $('#ddlListNames').val(); var checkValues = $('input[name=c]:checked').map(function () { return $(this).val(); }).toArray(); $.ajax({ url: '@Url.Action("Test1", "WordList")', type: 'POST', cache: false, data: { selectedListID: item }, success: function (result) { } }) .done(function (partialViewResult) { $("#divCheckBoxes").replaceWith(partialViewResult); }); }); }); Partial View: @model WLWeb.Models.MyModel <div id="divCheckBoxes"> @foreach (var item in Model.vwWordList) { @Html.Raw("<label><input type='checkbox' value='" + @Html.DisplayFor(modelItem => item.Word) + "' name='c'> " + @Html.DisplayFor(modelItem => item.Word) + "</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"); } </div> Controller: [AcceptVerbs(HttpVerbs.Post)] [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] public PartialViewResult Test1(MyModel vm, string[] words, string moveToListID, string selectedListID) { int listNameID = Convert.ToInt32(moveToListID); List<vwWordList> lst = db.vwWordLists.Where(s => s.Word.StartsWith("wa") && s.ListID == listNameID).ToList(); vm.vwWordList = lst; return PartialView("Partial1", vm); } View: @Html.DropDownListFor(x => Model.FilterViewModel.MoveToListNameID, Model.FilterViewModel.MoveToListNameList, new { @id = "ddlMoveToListNames", style = "width:100px;" })

    Read the article

  • Beginner to asp.net.. What should i choose webforms or mvc?

    - by MuraliVijay CSK
    I am new to web development and asp.net... I was going through asp.net website and 'n' number of question here in stackoverflow regarding Webforms or MVC.... But still as a beginner can't get an idea what to choose? What should i choose webforms or mvc? If MVC,What should i know before getting started with it? If webforms,What should i know before getting started with it?

    Read the article

  • Passing data from a View to a controller in ASP.Net MVC

    - by kingrichard2005
    Hello, I have a dictionary I'm passing to a View. I want to be able to pass the values of that dictionary back to a Controller action from this same View. Is there anyway this can be accomplished without using a form? The situation is that I need to be able to pass these back to a controller action that is called when a user clicks an ActionLink from the View, and in my experience an ActionLink cannot be used to submit a values of a form, i.e. I've only been able to submit values of a form using the form's submit button. Unless there's a way to use an ActionLink to submit values in a form.

    Read the article

  • asp.net mvc crazy error

    - by bongoo
    Hi there im having a weird error which is related to an earlier post , I am checking if a file exists before downloading. This works for pdf's but not for any other type of document here is my controller action and the typical path for a pdf and a powerpoint file , the powerpoint does not work ~/Documents//FID//TestDoc//27a835a5-bf70-4599-8606-6af64b33945d/FIDClasses.pdf ~/Documents//FID//pptest//ce36e7a0-14de-41f3-8eb7-0d543c7146fe/PPttest.ppt [UnitOfWork] public ActionResult Download(int id) { Document doc = _documentRepository.GetById(id); if (doc != null) { if (System.IO.File.Exists(Server.MapPath(doc.filepath))) { _downloadService.AddDownloadsForDocument(doc.document_id, _UserService.CurrentUser().user_id); return File(doc.filepath, doc.mimetype, doc.title); } } return RedirectToAction("Index"); }

    Read the article

  • ASP.NET MVC Return to Previous Page

    - by Jason Enochs
    I have a basic Edit method in my controller that redirects back to a top level listing (“Index”) when the edit succeeds. Standard setup after scaffolding. I am trying to change this Edit method to redirect back to the previous page (not Index). Since my Edit method is not using the default mapped input parameter “id”, I am using that to pass the previous URL. In my Edit “get” method, I use this line to grab the previous URL and it works fine: ViewBag.ReturnUrl = Request.UrlReferrer.AbsoluteUri; I send this return URL to the Edit “post” method by using my form tag like this: @using (Html.BeginForm(new { id = ViewBag.ReturnUrl })) Now this is where the wheels fall off. I can't seem to get the URL parsed from the id parameter properly. UPDATE**** Using Gary's example as a guide, I changing my parameter name from "id" to "returnUrl" and used a hidden field to pass my parameter. Lesson: Only use the id parameter how it was intended to be used...keep it simple. It works now... Here is my updated code. // // GET: /Question/Edit/5 public ActionResult Edit(int id) { Question question = db.Questions.Find(id); ViewBag.DomainId = new SelectList(db.Domains, "DomainId", "Name", question.DomainId); ViewBag.Answers = db.Questions .AsEnumerable() .Select(d => new SelectListItem { Text = d.Text, Value = d.QuestionId.ToString(), Selected = question.QuestionId == d.QuestionId }); ViewBag.returnUrl = Request.UrlReferrer; ViewBag.ExamId = db.Domains.Find(question.DomainId).ExamId; ViewBag.IndexByQuestion = string.Format("IndexByQuestion/{0}", question.QuestionId); return View(question); } // // POST: /Question/Edit/5 [HttpPost] public ActionResult Edit(Question question, string returnUrl) { int ExamId = db.Domains.Find(question.DomainId).ExamId; if (ModelState.IsValid) { db.Entry(question).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); return Redirect(returnUrl); } ViewBag.DomainId = new SelectList(db.Domains, "DomainId", "Name", question.DomainId); return View(question); } and I changed my form tag to this: @using (Html.BeginForm()) { <input type="hidden" name="returnUrl" value="@ViewBag.returnUrl" /> Thanks Gary

    Read the article

  • ASP MVC Controller Method not always called from $.getJSON request

    - by johnvpetersen
    I have a controller method that returns a jSON object and in one calling situation, it works and in another calling situation, it does not work. When the URL in my browser is this: http://localhost:65247/Client -- it works. But, when my url looks like this: http://localhost:65247/Client/UserAdmin?id=6 -- it DOES NOT work In a nutshell, clients have users. From within the client, I wish to work on a specific user (this is the UserAdmin view). In this case, the client id is 6. From within the UserAdmin view that was launched with Id=6, I then wish to select a user from a dropdown. The idea was to use javascript and $.getJSON to fetch data for the specific user so as not to have to refresh the entire page. I use this approach in other parts of the app. The only difference I can see is with the URL in the browser. It would appear the presence of parameters via the '?' is futzing things up a bit. Any ideas?? Thanks in advance. John

    Read the article

  • Using MembershipCreateStatus in MVC

    - by Jemes
    How can I use the MembershipCreateStatus in my controller below to identify errors? My controller below creates a new user but I would like to catch any errors from CreateStatus and add the error to my modelstate. [HttpPost] public ActionResult CreateUser(user UserToCreate) { if (ModelState.IsValid) { // TODO: If the UserToCreate object is Valid we'll //Eventually want to save it in a database Membership.CreateUser(UserToCreate.Username, UserToCreate.Password, UserToCreate.Email); return Redirect("/"); } //Invalid - redisplay form with errors return View(UserToCreate); }

    Read the article

  • ASP.NET MVC: when posted Upload File, it is null in action method

    - by Spencer
    In the View page, code is below: <% =Html.BeginForm("About", "Home", FormMethod.Post, new {enctype="multipart/form-data "})%> <input type ="file" name ="postedFile" /> <input type ="submit" name ="upload" value ="Upload" /> <% Html.EndForm(); %> In the Controller, something like this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult About(HttpPostedFile postedFile) { //but postedFile is null View(); } But postedFile is null, how to do it?

    Read the article

  • asp.net mvc HttpPostedFileBase getting file extension

    - by mazhar kaunain baig
    public string ContructOrganizationNameLogo(HttpPostedFileBase upload, string OrganizationName, int OrganizationID,string LangName) { var UploadedfileName = Path.GetFileName(upload.FileName); string type = upload.ContentType; } I want to get the extension of the file to dynamically generate the name of the file.One way i will use to split the type. but can i use HttpPostedFileBase object to get the extension in the clean way?

    Read the article

  • ASP.NET MVC Session across subdomains

    - by nccsbim071
    Hi, In my website i have implemented custom session values. In which, on log on i set the session value to some object. This object is used to extract user specific data from db. now the problem is If user logs in with : test1.somesite.com and logs off and again logs in with: test2.somesite.com that user is still receiving the data from object specific to test1.somesite.com. the point is whichever site user frist logs in with the second time if he logs in with anathor subdomain he is always getting the data from previous sub domain login. on log out from specific domain i cleared all the sessions(tried everything): by putting HttpContext.session["UserDetail"] = null;, HttpContext.Session.Abandon() and also HttpContext.Session.Clear(); but nothing seems to work any help please

    Read the article

  • Easiest way to specify the selected option to a dropdown list in ASP.NET MVC

    - by sdr
    I have a list of options (IEnumerable< SelectListItem ) in my model that I want to use in multiple dropdowns in my view. But each of these dropdowns could have a different selected option. Is there an easy way to simply specfiy which should be selected if using the Html.DropDownList helper? At this point, the only way I can see is to generate the html myself and loop through the list of options like so: <% for(int i=0; i<10; i++) { %> <select name="myDropDown<%= i %>"> <% foreach(var option in Model.Options) { %> <option value="<%= Html.Encode(option.optValue) %>" <%if(ShouldBeSelected(i)) {%> selected="selected"<% } %>><%= Html.Encode(option.optText) %></option> <% } %> </select> <% } %>

    Read the article

  • ASP.Net MVC null reference exception with TextArea name

    - by kingrichard2005
    Hello, I have a TextArea html helper method I'm calling in a foreach loop. Basically, when I initially load the View it works fine, but when i reload the View and load postback data, the same TextArea throws a NullReferencException and yet the variable I'm using in the TextArea as the name of the TextArea is not null. I've attached a picture below for demonstration: Sorry if it's difficult to see, the blue arrow below is pointing to the variable used to name the TextArea. Again, it works on initial load, but it errors out on postback when the page is reloaded. I'm not sure what's going on.

    Read the article

< Previous Page | 85 86 87 88 89 90 91 92 93 94 95 96  | Next Page >