asp.net-mvc-2

How do I create a strongly typed BeginForm?

拟墨画扇 提交于 2019-12-02 00:28:01
问题 I've seen a few examples of people using this syntax for HTML.BeginForm: (Html.BeginForm<Type>(action => action.ActionName(id))) But when I try this syntax all I get is a: The non-generic method System.Web.Mvc.Html.FormExtensions.BeginForm(System.Web.Mvc.HtmlHelper)' cannot be used with type arguments What am I missing? Visual Studio 2010, System.Web.MVC version is v2.0.50727 回答1: You will find this extension methods in MVCContrib and more specifically in the Microsoft.Web.Mvc.dll assembly in

Areas over multiple projects - Views not found in child projects

梦想的初衷 提交于 2019-12-01 23:09:39
问题 I've been following this guide from MSDN about "Creating an ASP.NET MVC Areas Application Using Multiple Projects". Since ASP.NET MVC 2.0 is just preview one would imagine there to be some bugs. My problem is, it simply doesn't work! At least not the way it's suppose to. After setting everything up and pressing F5, one would think that, this will work, neat! BEEEP. Wrong. It doesn't find the Views in the child project! Because in my case it tries to search within ~/Views which of course is in

ASP.NET MVC Add View Dialog closing

若如初见. 提交于 2019-12-01 23:08:15
问题 Recently a large project I work on started having a problem with the Add View dialog. When clicking the Add Strongly-typed View checkbox, the spinner comes up the first time for about a second or two, and then the entire dialog just closes and disappears. If I open the dialog and click the button again, it just closes again quickly. The project is using ASP.NET MVC 2, I have installed VS2010 SP1 and this problem occurs with or without the MVC3 tools update installed. It only happens with this

Telerik MVC custom AJAX editor template

ⅰ亾dé卋堺 提交于 2019-12-01 23:06:56
问题 I am using the MVC version of the Telerik controls with ASP.NET MVC and the razor view engine . I have an AJAX grid. When I click edit I want it to display the data in form style. But the issue is that I want to rearrange the in form controls they way that I want them to display. How would I do something like that? Currently the controls are all beneath each other. I want to create my own layout for editing. I have a whole lot of other controls on the view, one of them being this grid. My

Create HtmlHelper instance in Controller

╄→尐↘猪︶ㄣ 提交于 2019-12-01 22:19:31
I need to do with HtmlHelper in Controller, so how i create it in Controller (asp.net mvc 2.0)? griegs Is this what you want? Using HtmlHelper in a Controller EDIT Use this; System.IO.TextWriter writer = new System.IO.StringWriter(); var h = new HtmlHelper(new ViewContext(ControllerContext, new WebFormView("omg"), new ViewDataDictionary(), new TempDataDictionary(), writer), new ViewPage()); string g = h.TextBox("myname").ToString(); You can use method like this: public static HtmlHelper GetHtmlHelper(this Controller controller) { var viewContext = new ViewContext(controller.ControllerContext,

Areas over multiple projects - Views not found in child projects

给你一囗甜甜゛ 提交于 2019-12-01 21:09:50
I've been following this guide from MSDN about "Creating an ASP.NET MVC Areas Application Using Multiple Projects" . Since ASP.NET MVC 2.0 is just preview one would imagine there to be some bugs. My problem is, it simply doesn't work! At least not the way it's suppose to. After setting everything up and pressing F5, one would think that, this will work, neat! BEEEP. Wrong. It doesn't find the Views in the child project! Because in my case it tries to search within ~/Views which of course is in the parent! When debugging i see that it Does run the Controller inside my child project, but when

Telerik MVC custom AJAX editor template

故事扮演 提交于 2019-12-01 20:45:50
I am using the MVC version of the Telerik controls with ASP.NET MVC and the razor view engine . I have an AJAX grid. When I click edit I want it to display the data in form style. But the issue is that I want to rearrange the in form controls they way that I want them to display. How would I do something like that? Currently the controls are all beneath each other. I want to create my own layout for editing. I have a whole lot of other controls on the view, one of them being this grid. My view model object has a list of Children objects and I want to use my grid to populate this list. The view

Problem performing Ajax call from ASP.NET MVC2 app

微笑、不失礼 提交于 2019-12-01 20:40:39
I'm converting an existing ASP.NET app to MVC2, and I have an existing method that is called through jQuery using Ajax, that worked before, but does not work now. So it seems there are some change I need to do due to using MVC2 that I can't figure out. I have reduced the complexity of the code, but it still do not work. This is my current code: jQuery script that trigger on button click function leaveComment() { if (validate()) { $.ajax({ type: "POST", url: "/Pages/PostBlogComment", data: "{'name':'Test','url':'Test','email':'Test','body':'Test','postid':'Test'}", dataType: "json", success:

ASP.NET MVC 2 RC client side validation not working

不羁岁月 提交于 2019-12-01 20:11:32
问题 I can't seem to get any client side validation working on a MVC 2 RC app. My model has the following: public class ExampleModel { [Required(ErrorMessage="Test1 is required")] [DisplayName("Test1")] public string Test1 { get; set; } [Required(ErrorMessage="Test2 is required")] [DisplayName("Test2")] public string Test2 { get; set; } } My view has the following code: <% Html.EnableClientValidation(); %> <%= Html.ValidationSummary(true, "Test was unsuccessful.") %> <% using (Html.BeginForm()) {

How to allow download of file, that is returned as binary data from AJAX

ぃ、小莉子 提交于 2019-12-01 19:44:32
My problem is that I send to client first PDF to download, then I need to check, if some data exists in my database, then depending on that check I need to show question that if user want to download another PDF, that I generates. My Code: //Here I just make dialog for question $('#printDWInfo').dialog({ resizable: false, modal: true, autoOpen: false }); //Here is my problem :) $('#generujWydruk').click(function (event) { event.preventDefault(); $('#printForm').submit(); // <-- sending first request and client get first PFD file $.post('<%: ResolveUrl("~/Reports/KPiRReportDWCheck") %>', <--