Search Results

Search found 386 results on 16 pages for 'viewdata'.

Page 13/16 | < Previous Page | 9 10 11 12 13 14 15 16  | Next Page >

  • .Net MVC UserControl - Form values not mapped to model

    - by Andreas
    Hi I have a View that contains a usercontrol. The usercontrol is rendered using: <% Html.RenderPartial("GeneralStuff", Model.General, ViewData); %> My problem is that the usercontrol renders nicely with values from the model but when I post values edited in the usercontrol they are not mapped back to Model.General. I know I can find the values in Request.Form but I really thought that MVC would manage to map these values back to the model. My usercontrol: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<namespace.Models.GeneralViewModel>" %> <fieldset> <div> <%= Html.LabelFor(model => model.Value)%> <%= Html.TextBoxFor(model => model.Value)%> </div> </fieldset> I'm using .Net MVC 2 Thanks for any help!

    Read the article

  • inbound/outbound url routing in asp.net MVC

    - by Stephane
    The routing I need is quite simple, I must be missing something there. As code example I put the simpler situation where I can reproduce my behavior. You have this ActionMethod : public ActionResult Index(string provider) { ViewData["Message"] = provider; return View("Index"); } And you have this route : routes.MapRoute( null, "{controller}/{action}/{provider}", new { controller = "Home", action = "Index", provider = "Default" } ); // Parameter defaults You can call /Home/Index/Custom and provider will take the value "Custom" What Route would I need if I want the url /?provider=Custom to map the provider to the parameter. I thought that would just work, because the default controller and the default action would be used, and the provider from the querystring would be used instead of the default one. but the querystring is just ignored here. That's a problem in my situation as I have a form using HTTP GET method. The form action has to be Html.BeginForm(c=c.Index(null)) which is resolved as / and the value of my form are added in the querystring. (the provider being a dropdown in the form) So the url built by the form is /?abc=value&cde=value...

    Read the article

  • How to test views in ASP.NET MVC2 (ala RSpec)

    - by Dmitriy Nagirnyak
    Hi, I am really missing heavily the ability to test Views independently of controllers. The way RSpec allows to do it. What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid of HttpContext!). So far I have not found anything that allows doing it. Also it might heavily depend on the ViewEngine being used. List of things that views might contain are: Partial views (may be nested deeply). Master pages (or similar in other view engines). Html helpers generating links and other elements. Generally almost anything in a range of common sense :) . Also please note that I am not talking about client-side testing and thus Selenium is just not related to it at all. It is just plain .NET testing. So are there any options to actually do the testing of views? Thanks, Dmitriy.

    Read the article

  • Render label for a field inside ASP.NET MVC 2 editor templates

    - by artvolk
    I'm starting to use DataAnnotations in ASP.NET MVC and strongly typed template helpers. Now I have this in my views (Snippet is my custom type, Created is DateTime): <tr> <td><%= Html.LabelFor(f => Model.Snippet.Created) %>:</td> <td><%= Html.EditorFor(f => Model.Snippet.Created)%></td> </tr> The editor template for DateTime is like this: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime>" %> <%=Html.TextBox("", Model.ToString("g"))%> But now I want to put inside editor template the whole <tr>, so I'd like to have just this in my view: <%= Html.EditorFor(f => Model.Snippet.Created)%> And something like this in editor template, but I don't know how to render for for label attribute, it should be Snippet_Created for my example, the same as id\name for textbox, so pseudo code: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.DateTime>" %> <tr> <td><label for="<What to place here???>"><%=ViewData.ModelMetadata.DisplayName %></label></td> <td><%=Html.TextBox("", Model.ToString("g"))%></td> </tr> The Html.TextBox() have the first parameter empty and id\name for textbox is generated corectly. Thanks in advance!

    Read the article

  • Entity Framework with ASP.NET MVC. Updating entity problem

    - by Kitaly
    Hi people. I'm trying to update an entity and its related entities as well. For instance, I have a class Car with a property Category and I want to change its Category. So, I have the following methods in the Controller: public ActionResult Edit(int id) { var categories = context.Categories.ToList(); ViewData["categories"] = new SelectList(categories, "Id", "Name"); var car = context.Cars.Where(c => c.Id == id).First(); return PartialView("Form", car); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(Car car) { var category = context.Categories.Where(c => c.Id == car.Category.Id).First(); car.Category = category; context.UpdateCar(car); context.SaveChanges(); return RedirectToAction("Index"); } The UpdateCar method, in ObjectContext class, follows: public void UpdateCar(Car car) { var attachedCar = Cars.Where(c => c.Id == car.Id).First(); ApplyItemUpdates(attachedCar, car); } private void ApplyItemUpdates(EntityObject originalItem, EntityObject updatedItem) { try { ApplyPropertyChanges(originalItem.EntityKey.EntitySetName, updatedItem); ApplyReferencePropertyChanges(updatedItem, originalItem); } catch (InvalidOperationException ex) { Console.WriteLine(ex.ToString()); } } public void ApplyReferencePropertyChanges(IEntityWithRelationships newEntity, IEntityWithRelationships oldEntity) { foreach (var relatedEnd in oldEntity.RelationshipManager.GetAllRelatedEnds()) { var oldRef = relatedEnd as EntityReference; if (oldRef != null) { var newRef = newEntity.RelationshipManager.GetRelatedEnd(oldRef.RelationshipName, oldRef.TargetRoleName) as EntityReference; oldRef.EntityKey = newRef.EntityKey; } } } The problem is that when I set the Category property after the POST in my controller, the entity state changes to Added instead of remaining as Detached. How can I update one-to-one relationship with Entity Framework and ASP.NET MVC without setting all the properties, one by one like this post?

    Read the article

  • Pass a hidden jqGrid value when editing on ASP.Net MVC

    - by taylonr
    I have a jqGrid in an ASP.Net MVC. The grid is defined as: $("#list").jqGrid({ url: '<%= Url.Action("History", "Farrier", new { id = ViewData["horseId"]}) %>', editurl: '/Farrier/Add', datatype: 'json', mtype: 'GET', colNames: ['horseId', 'date', 'notes'], colModel: [ { name: 'horseId', index: 'horseId', width: 250, align: 'left', editable:false, editrules: {edithidden: true}, hidden: true }, { name: 'date', index: 'farrierDate', width: 250, align: 'left', editable:true }, { name: 'notes', index: 'farrierNotes', width: 100, align: 'left', editable: true } ], pager: jQuery('#pager'), rowNum: 5, rowList: [5, 10, 20, 50], sortname: 'farrierDate', sortorder: "DESC", viewrecords: true }); What I want to be able to do, add a row to the grid, where the horseId is either a) not displayed or b) greyed out. But is passed to the controller when saving. The way it's set up is this grid will only have 1 horse id at a time (it will exist on a horse's property page.) The only time I've gotten anything to work is when I made it editable, but then that opens it up for the user to modify the id, which isn't a good idea. So is there some way I can set this value before submitting the data? it does exist as a variable on this page, if that helps any (and I've checked that it isn't null). Thanks

    Read the article

  • How can i Execute a Controller's ActionMethod programatically?

    - by Pure.Krome
    Hi folks, I'm trying to execute a controller's Action Method programatically and I'm not sure how. Scenario: When my ControllerFactory fails to find the controller, I wish it to manually execute a single action method which i have on a simple, custom controller. I don't want to rely on using any route data to determine the controller/method .. because that route might not have been wired up. Eg. // NOTE: Error handling removed from this example. public class MyControllerFactory : DefaultControllerFactory { protected override IController GetControllerInstance(Type controllerType) { IController result = null; // Try and load the controller, based on the controllerType argument. // ... snip // Did we retrieve a controller? if (controller == null) { result = new MyCustomController(); ((MyCustomController)result).Execute404NotFound(); // <-- HERE! } return result; } } .. and that method is .. public static void Execute404NotFound(this Controller controller) { result = new 404NotFound(); // Setup any ViewData.Model stuff. result.ExecuteResult(controller.ControllerContext); // <-- RUNTIME // ERROR's HERE } Now, when I run the controller factory fails to find a controller, i then manually create my own basic controller. I then call the extension method 'Execute404NotFound' on this controller instance. That's fine .. until it runs the ExecuteResult(..) method. Why? the controller has no ControllerContext data. As such, the ExecuteResult crashes because it requires some ControllerContext. So - can someone out there help me? see what I'm doing wrong. Remember - i'm trying to get my controller factory to manually / programmatically call a method on a controller which of course would return an ActionResult. Please help!

    Read the article

  • Retrive data from two tables in asp.net mvc using ADO.Net Entity Framework

    - by user192972
    Please read my question carefully and reply me. I have two tables as table1 and table2. In table1 i have columns as AddressID(Primary Key),Address1,Address2,City In table2 i have columns as ContactID(Primary Key),AddressID(Foriegn Key),Last Name,First Name. By using join operation i can retrive data from both the tables. I created a Model in my MVC Application.I can see both the tables in enitity editor. In the ViewData folder of my solution explorer i created two class as ContactViewData.cs and SLXRepository.cs In the ContactViewData.cs i have following code public IEnumerable<CONTACT> contacts { get; set; } In the SLXRepository.cs i have following code public IEnumerable<CONTACT> GetContacts() { var contact = ( from c in context.CONTACT join a in context.ADDRESS on c.ADDRESSID equals a.ADDRESSID select new { a.ADDRESS1, a.ADDRESS2, a.CITY, c.FIRSTNAME, c.LASTNAME } ); return contact; } I am getting the error in return type Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?)

    Read the article

  • How to html encode the output of an NHaml view (or any MVC view)?

    - by jessegavin
    I have several views written in NHaml that I would like to render as encoded html. Here's one. %table.data %thead %tr %th Country Name %th ISO 2 %th ISO 3 %th ISO # %tbody - foreach(var c in ViewData.Model.Countries) %tr %td =c.Name %td =c.Alpha2 %td =c.Alpha3 %td =c.Number I know that NHaml provides syntax to Html encode the output for given lines using &=. However, in order to encode the entire view, I would essentially lose the benefit of writing my view in NHaml since it would have to look like this.... &= "<table class='data'> &= " <thead> So I was wondering if there was any cool way to be able to capture the rendered view as a string, then to html encode that string. Maybe something like the following??? public ContentResult HtmlTable(string format) { var m = new CountryViewModel(); m.Countries = _countryService.GetAll(); // Somehow render the view and store it as a string? // Not sure how to achieve this. var viewHtml = View("HtmlTable", m); // ??? return Content(viewHtml); } This question may actually have no particular relevance to the View engine that I am using I guess. Any help or thoughts would be appreciated.

    Read the article

  • Test Views in ASP.NET MVC2 (ala RSpec)

    - by Dmitriy Nagirnyak
    Hi, I am really missing heavily the ability to test Views independently of controllers. The way RSpec does it. What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid of HttpContext!). So far I have not found anything that allows doing it. Also it might heavily depend on the ViewEngine being used. List of things that views might contain are: Partial views (may be nested deeply). Master pages (or similar in other view engines). Html helpers generating links and other elements. Generally almost anything in a range of common sense :) . Also please note that I am not talking about client-side testing and thus Selenium is just not related to it at all. It is just plain .NET testing. So are there any options to actually do the testing of views? Thanks, Dmitriy.

    Read the article

  • ASP.NET MVC: Returning a view with querystring in tact

    - by ajbeaven
    I'm creating a messaging web app in ASP.NET and are having some problems when displaying an error message to the user if they go to send a message and there is something wrong. A user can look through profiles of people and then click, 'send a message'. The following action is called (url is /message/create?to=username) and shows them a page where they can enter their message and send it: public ActionResult Create(string to) { ViewData["recipientUsername"] = to; return View(); } On the page that is displayed, the username is entered in to a hidden input field. When the user clicks 'send': [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(string message, string to) { try { //do message stuff that errors out } catch { ModelState.AddModelErrors(message.GetRuleViolations()); //adding errors to modelstate } return View(); } So now the error message is displayed to the user fine, however the url is changed in that it no longer has the querystring (/message/create). Again, this would be fine except that when the user clicks the refresh button, the page errors out as the Create action no longer has the 'to' parameter. So I'm guessing that I need to maintain my querystring somehow. Is there any way to do this or do I need to use a different method altogether?

    Read the article

  • How to transfer value from a DropDownList to a property of a serialized model object

    - by Richard77
    Hello, I'm testing some concepts in ASP.NET MVC multisteps (Style Wizards) with a small application which allow me to records organizations in a database. To make things easier, I've a class OrganizationFormModelView that contains an object of class Organization and a property called ParentOrgList of SelectList type. The only purpose of the selectList property is to be used by a DropDownList. I've also serialize OrganizationFormModelView to get the multisteps Wizard effect. In my first view (or first step), I use a dropdownlist helper to assign a value to one of the the Organization's property called ParentOrganization, which draws data from the ParentOrgList. ... <% = Html.DropDownList("Organization.ParentOrganization", Model.ParentOrgList)%> ... The first time the page loads, I'm able to make a choice. And, my choice is reflected in my object Model all along the wizard' steps(see Visual studio in debugging mode). But, when any time I'm redirected back to the first view (first step), I get the following error message: "The ViewData item with the key 'Organization.ParentOrganization' is of type 'System.String' but needs to be of type 'IEnumerable'." Thanks for helping

    Read the article

  • How do I retrieve row ID from an MVCContrib HTML Grid?

    - by ryandreggs
    Hi, I currently have a product view page that contains an MVCContrib HTML Grid with a select link at the beginning of each row. If the select link is clicked, it takes me to a different page. My question is whether it is possible to retrieve the productID from the row that is selected and pass that to the next page. Maybe this is posible to do with a session variable but im not sure. Any help would be greatly appreciated. Thanks in advance. Here is my view code: <% Html.Grid((List<System2__MVC2.Controllers.ProductController.ProductsSet>)ViewData["Products"]).Columns(column => { column.For(c => Html.ActionLink("Select", "Products", "Product")).DoNotEncode(); column.For(c => c.ProductID); column.For(c => c.Name); column.For(c => c.Description); column.For(c => c.Price); }).Render(); %>

    Read the article

  • MVC Paging and Sorting Patterns: How to Page or Sort Re-Using Form Criteria

    - by CRice
    What is the best ASP.NET MVC pattern for paging data when the data is filtered by form criteria? This question is similar to: http://stackoverflow.com/questions/1425000/preserve-data-in-net-mvc but surely there is a better answer? Currently, when I click the search button this action is called: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Search(MemberSearchForm formSp, int? pageIndex, string sortExpression) {} That is perfect for the initial display of the results in the table. But I want to have page number links or sort expression links re-post the current form data (the user entered it the first time - persisted because it is returned as viewdata), along with extra route params 'pageIndex' or 'sortExpression', Can an ActionLink or RouteLink (which I would use for page numbers) post the form to the url they specify? <%= Html.RouteLink("page 2", "MemberSearch", new { pageIndex = 1 })%> At the moment they just do a basic redirect and do not post the form values so the search page loads fresh. In regular old web forms I used to persist the search params (MemberSearchForm) in the ViewState and have a GridView paging or sorting event reuse it.

    Read the article

  • Create serial number column in telerik mvc grid

    - by Jayaraj
    I could create a grid with telerik mvc <% Html.Telerik().Grid(Model) .Name("ProductGrid") .Columns(columns => { columns.Bound(h => h.ProductName).Width("34%"); columns.Bound(h => h.Description).Width("60%"); columns.Bound(h => h.ProductID).Format(Html.ImageLink("Edit", "Products", new { Id = "{0}" }, "/Content/images/icon_edit.gif", "", new { Id = "edit{0}" }, null).ToString()).Encoded(false).Title("").Sortable(false).Width("3%"); columns.Bound(h => h.ProductID).Format(Html.ImageLink("Delete", "Products", new { Id = "{0}" }, "/Content/images/icon_delete.gif", "", new { onclick = string.Format("return confirm('Are you sure to delete this add on?');") },null).ToString()).Encoded(false).Title("").Sortable(false).Width("3%"); }) .EnableCustomBinding(true) .DataBinding(databinding => databinding.Ajax().Select("_Index", "ProductGrid")) .Pageable(settings => settings.Total((int)ViewData["TotalPages"]) .PageSize(10)) .Sortable() .Render(); %> but I need to add a serial number column in telerik grid.How can i do this?

    Read the article

  • How do I assert that two arbitrary type objects are equivalent, without requiring them to be equal?

    - by Tomas Lycken
    To accomplish this (but failing to do so) I'm reflecting over properties of an expected and actual object and making sure their values are equal. This works as expected as long as their properties are single objects, i.e. not lists, arrays, IEnumerable... If the property is a list of some sort, the test fails (on the Assert.AreEqual(...) inside the for loop). public void WithCorrectModel<TModelType>(TModelType expected, string error = "") where TModelType : class { var actual = _result.ViewData.Model as TModelType; Assert.IsNotNull(actual, error); Assert.IsInstanceOfType(actual, typeof(TModelType), error); foreach (var prop in typeof(TModelType).GetProperties()) { Assert.AreEqual(prop.GetValue(expected, null), prop.GetValue(actual, null), error); } } If dealing with a list property, I would get the expected results if I instead used CollectionAssert.AreEquivalent(...) but that requires me to cast to ICollection, which in turn requries me to know the type listed, which I don't (want to). It also requires me to know which properties are list types, which I don't know how to. So, how should I assert that two objects of an arbitrary type are equivalent? Note: I specifically don't want to require them to be equal, since one comes from my tested object and one is built in my test class to have something to compare with.

    Read the article

  • How to get these values front end using asp.net mvc

    - by kumar
    hello friends, <div> <label> Date: <span><input type="text" id="date" /></span> <%--<%=Html.EditorFor(model=>model.Date) %>--%> // Should I use this as Input type? </label> <label> Number#: <%=Html.TextBox("Number", ViewData["inq"] ?? "")%> </label> <label>Comment</label> <span> <%=Html.TextArea("value")%> <%=Html.ValidationMessage("value")%> </span> </div> I am trying to get these three fields on the screen while user enters I am retreving the user enter data on front end.. when I am debugging I am not seeing these fields.. On the view I am using beginForm <% using (Html.BeginForm("Update", "Home", FormMethod.Post, new { @id = "id" })) { %> my method.. public JsonResult Update(StudentInfo info) { Update/// return Json(Status.ToString()); } when I see in info I am not getting these three fields.. can any one help me out thanks

    Read the article

  • ASP.NET MVC: Returning a view with querystring intact

    - by ajbeaven
    I'm creating a messaging web app in ASP.NET and are having some problems when displaying an error message to the user if they go to send a message and there is something wrong. A user can look through profiles of people and then click, 'send a message'. The following action is called (url is /message/create?to=username) and shows them a page where they can enter their message and send it: public ActionResult Create(string to) { ViewData["recipientUsername"] = to; return View(); } On the page that is displayed, the username is entered in to a hidden input field. When the user clicks 'send': [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection, string message) { try { //do message stuff that errors out } catch { ModelState.AddModelErrors(message.GetRuleViolations()); //adding errors to modelstate } return View(); } So now the error message is displayed to the user fine, however the url is changed in that it no longer has the querystring (/message/create). Again, this would be fine except that when the user clicks the refresh button, the page errors out as the Create action no longer has the 'to' parameter. So I'm guessing that I need to maintain my querystring somehow. Is there any way to do this or do I need to use a different method altogether?

    Read the article

  • How can I properly handle 404s in ASP.NET MVC?

    - by Brian
    I am just getting started on ASP.NET MVC so bear with me. I've searched around this site and various others and have seen a few implementations of this. EDIT: I forgot to mention I am using RC2 Using URL Routing: routes.MapRoute( "Error", "{*url}", new { controller = "Errors", action = "NotFound" } //404s ); The above seems to take care of requests like this (assuming default route tables setup by initial MVC project): "/blah/blah/blah/blah" Overriding HandleUnknownAction() in the controller itself: //404s - handle here (bad action requested protected override void HandleUnknownAction(string actionName) { ViewData["actionName"] = actionName; View("NotFound").ExecuteResult(this.ControllerContext); } However the previous strategies do not handle a request to a Bad/Unknown controller. For example, I do not have a "/IDoNotExist", if I request this I get the generic 404 page from the web server and not my 404 if I use routing + override. So finally, my question is: Is there any way to catch this type of request using a route or something else in the MVC framework itself? OR should I just default to using Web.Config customErrors as my 404 handler and forget all this? I assume if I go with customErrors I'll have to store the generic 404 page outside of /Views due to the Web.Config restrictions on direct access. Anyway any best practices or guidance is appreciated.

    Read the article

  • How to handle checkboxes in ASP.NET MVC forms?

    - by Will
    This seems a bit bizarre to me, but as far as I can tell, this is how you do it. I have a collection of objects, and I want users to select one or more of them. This says to me "form with checkboxes." My objects don't have any concept of "selected" (they're rudimentary POCO's formed by deserializing a wcf call). So, I do the following: public class SampleObject{ public Guid Id {get;set;} public string Name {get;set;} } In the view: <% using (Html.BeginForm()) { %> <%foreach (var o in ViewData.Model) {%> <%=Html.CheckBox(o.Id)%>&nbsp;<%= o.Name %> <%}%> <input type="submit" value="Submit" /> <%}%> And, in the controller, this is the only way I can see to figure out what objects the user checked: public ActionResult ThisLooksWeird(FormCollection result) { var winnars = from x in result.AllKeys where result[x] != "false" select x; // yadda } Its freaky in the first place, and secondly, for those items the user checked, the FormCollection lists its value as "true false" rather than just true. Obviously, I'm missing something. I think this is built with the idea in mind that the objects in the collection that are acted upon within the html form are updated using UpdateModel() or through a ModelBinder. But my objects aren't set up for this; does that mean that this is the only way? Is there another way to do it?

    Read the article

  • asp.net mvc multiple fckeditors field

    - by mazhar kaunain baig
    how to add multiple fckeditor field on asp.net mvc page ok here is the code <% foreach (var OrganizationMeta in ((IEnumerable<Egovt.Models.OrganizationMeta>)ViewData["OrganizationMeta"])) { %> <% if (OrganizationMeta.vcr_DateType == "text") { %> <% TempData["OrganizationMeta"] = OrganizationMeta.vcr_MetaKey + Lang.int_LangId; %> <% Html.RenderPartial("ControlRender"); %> <% } %> <% } %> </div> controlrender <script src="<%= Url.Content("~/Content/js/fck/fckeditor.js") %>" type="text/javascript"></script> <script type="text/javascript"> window.onload = function() { var sBasePath = '<%= Url.Content("~/Content/js/fck/") %>'; var oFCKeditor = new FCKeditor('<%=TempData["OrganizationMeta"] %>'); oFCKeditor.BasePath = sBasePath; oFCKeditor.ReplaceTextarea(); } </script> <%= Html.TextArea(TempData["OrganizationMeta"].ToString(),"", new { @name = TempData["OrganizationMeta"] })%> How will i implement it

    Read the article

  • How to use html.grid control in spark view for asp.net mvc?

    - by Anusha
    class person() { public int Id{get;set;} public string Name{get;set;} } HomeController.cs ActionResult Index() { IList list=new[]{ new person { Id = 1, Name = "Name1" }, new person { Id = 2, Name = "Name2" }, new person { Id = 3, Name = "Name3" } }; ViewData["mygrid"]=list; return view(); } Home\Index.spark !{Html.Grid[[person]]("mygrid", (column=>{ column.For(c=>c.Id); column.For(c=>c.Name); })) Am getting the error Dynamic view compilation failed..error CS1501: No overload for method 'Grid' takes '2' arguments. I have added reference to MvcContrib.dll And added following namespace in the _global.spark file <use namespace="MvcContrib.UI"/> <use namespace="MvcContrib.UI.Grid"/> <use namespace="MvcContrib.UI.Pager"/> <use namespace="MvcContrib.UI.Grid.ActionSyntax"/> <use namespace="Microsoft.Web.Mvc.Controls"/> I want to bind the data to my grid in spark view.Can anybody help.

    Read the article

  • JQuery error in IE, works with FF. Maybe a problem with live.

    - by olve
    Hello. I have an ASP.net MVC2 application. In wich I'm using JQuery to alter all table rows so I can click anywhere in any row to trigger a click event on a link in the clicked row. The tables is created using MVC's built in partialview ajax. Here is my JQuery script. <script type="text/javascript"> $(document).ready(function () { $('table tr').live('click',function (event) { $('#asplink', this).trigger('click'); }) .live('mouseenter',function (event) { this.bgColor = 'lightblue'; }) .live('mouseleave', function (event) { this.bgColor = 'white'; }); }); </script> And this is the first part of the partial view code that creates the table. <% foreach (var item in Model.JobHeaderData) { %> <tr> <td> <a id="asplink" href="http://localhost/sagstyring/EditJob.asp?JobDataID=<%: item.JobDataId %>&JobNumId=<%: item.JobNumID%>&JobNum=<%: item.JobNumID%>&DepId=1&User_Id=<%:ViewData["UserId"]%>" onclick="window.open(this.href,'Rediger sag <%: item.JobNumID %> ', 'status=0, toolbar=0, location=0, menubar=0, directories=0, resizeable=0, scrollbars=0, width=900, height=700'); return false;">Rediger</a> </td> In firefox this works perfectly. In IE, JQuery crashes when I click on a row. If I debug the page in IE. I get this. Out of stack space In jquery-1.4.1.js line 1822 // Trigger the event, it is assumed that "handle" is a function var handle = jQuery.data( elem, "handle" ); if ( handle ) { handle.apply( elem, data ); } I'm no eagle at javascript, so I'm pretty much stuck.

    Read the article

  • how to rotate around each record in linq and show that in view

    - by Sadegh
    Hi, I have four tables in my database and i want to join that's and return record's and show that into searchController! My query is this: public IQueryable PerformSearch(string query) { if (!string.IsNullOrEmpty(query)) { var results = from tbl1 in context.Table1 join tbl2 in context.Table2 on tbl1.Id equals tbl2.Id join tbl3 in context.Table3 on tbl2.Id equals tbl3.Id join tbl4 in context.Table4 on tbl3.Id equals tbl4.Id where tbl1.col2.Contains(query) orderby tbl1.Count descending select new { col1 = tbl1.Col1, col1 = tbl1.Col1, col1 = tbl1.Col1, . . . }; return results.AsQueryable(); } else return null; } And this method called in SearchController as below: public class SearchController : System.Web.Mvc.Controller { public System.Web.Mvc.ActionResult Search(System.String query) { var search = new Search(); ViewData["result"] = search.PerformSearch(query); return View("Search"); } } I don't know how i can rotate around each record (plus vs intellisense feature) returned by PeformSeach method and show that in view! Also is this a good way? thanks in advance

    Read the article

  • What is the easiest way to get the property value from a passed lambda expression in an extension me

    - by Andrew Siemer
    I am writing a dirty little extension method for HtmlHelper so that I can say something like HtmlHelper.WysiwygFor(lambda) and display the CKEditor. I have this working currently but it seems a bit more cumbersome than I would prefer. I am hoping that there is a more straight forward way of doing this. Here is what I have so far. public static MvcHtmlString WysiwygFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { return MvcHtmlString.Create(string.Concat("<textarea class=\"ckeditor\" cols=\"80\" id=\"", expression.MemberName(), "\" name=\"editor1\" rows=\"10\">", GetValue(helper, expression), "</textarea>")); } private static string GetValue<TModel, TProperty>(HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { MemberExpression body = (MemberExpression)expression.Body; string propertyName = body.Member.Name; TModel model = helper.ViewData.Model; string value = typeof(TModel).GetProperty(propertyName).GetValue(model, null).ToString(); return value; } private static string MemberName<T, V>(this Expression<Func<T, V>> expression) { var memberExpression = expression.Body as MemberExpression; if (memberExpression == null) throw new InvalidOperationException("Expression must be a member expression"); return memberExpression.Member.Name; } Thanks!

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16  | Next Page >