asp.net-mvc-2

Sorting out my Site.Master

耗尽温柔 提交于 2019-12-13 06:41:44
问题 So I am talking about links in a Asp.net mvc2 application, where you have a site master. In particular, my Site.Master references jQuery, like so: <head runat="server"> <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title> <script type="text/javascript" src="../../Scripts/jquery-1.4.1.js"></script> But lo an behold, as I have just noticed, this obv isn't going to work e.g. http://localhost:xxxx/ http://localhost:xxxx/this/no/longer/refs/correct/spot How can I reference

DropdownlistFor throws an error

99封情书 提交于 2019-12-13 06:31:58
问题 I am using hardcoded string values for dropdownlist to the view , and passing the selected value from database , where 0 = pending , 1 = complete and 3 = awaiting, below is the code for view and controller: var paymentStatus = new[] { "Pending", "Complete", "AwaitingPayment" }; ViewData["StatusID"] = new SelectList(paymentStatus, "Value", "Text", booking.StatusID); <tr><td>Status</td><td><%: Html.DropDownListFor(m => m.StatusID, ViewData["StatusID"] as SelectList)%></td></tr> It comes up with

ASP.NET MVC2 Checkboxes in a table

拈花ヽ惹草 提交于 2019-12-13 05:45:48
问题 I'm currently trying to create a view in asp.net MVC2 which includes a checkbox in each row. This will be a "mark" box, and there will be a button on the view which can then be used for multiple deletion. I have a model which contains a list of the objects being listed, so I have some code which reads as:- <% foreach (CancelledCard item in Model.CancelledCards) { %> I've then tried to use <%: Html.CheckBoxFor(item >= item.Checked) %> but I'm getting an error. What am I missing? What's the

Programmatically configure ActiveRecordFacility for multiple databases

ぃ、小莉子 提交于 2019-12-13 05:45:48
问题 I'm trying to build a small application (ASP.NET MVC) that uses the plugin architecture. Along with Castle ActiveRecord Integration Facility. And I wish to let each plugin configure its own ActiveRecord behaviors. Like database connection string, proxy, etc.. However, I couldn't find a way to set multiple configurations without the use of web.config. The idea is to make this programmatically. My goal is for each plugin in this system, if it defines its own ActiveRecord settings, the main

My Own javascript validation + MicrosoftMvcValidation . Is it possible ? How

戏子无情 提交于 2019-12-13 05:40:55
问题 I would like to be able to use the MVC validation + my custom javascript validation. The MVC validation is really nice for Model Validation. The main problem here, is that I have more complexe validation. Ex: Case with MVC Validation <div class="editorSmall"> <div class="editor-label bold"> <%: Html.LabelFor(model => model.Location.CurID)%>: </div> <div class="editor-field"> <%:Html.DropDownListFor(model => model.Location.CurID, Model.CurrenciesList)%> <%: Html.ValidationMessageFor(model =>

Passing Parameters from textboxes in a view to a controller in ASP.Net MVC2

∥☆過路亽.° 提交于 2019-12-13 05:22:06
问题 I am trying out ASP.Net MVC2 by building a small sample website which, amongst other features provides the user with a 'Contact Us' page. The idea is to allow a user to enter their name, email address, message subject and message. To send the message the user clicks on an ActionLink. This is the view: <% Html.BeginForm(); %> <div> <%: Html.Label("Name")%> <br /> <%: Html.TextBox("txtName", "",new { style = "width:100%" })%> <br /> <%: Html.Label("Email address")%> <br /> <%: Html.TextBox(

MVC 2.0, StructureMap, Areas, and Duplicate Controller Names

江枫思渺然 提交于 2019-12-13 05:14:09
问题 I have a bit of a problem. I have an area called Framed. This area has a home controller. The default for the site also has a home controller. What I'm trying to do with this is have a version of each controller/action that is suitable for an IFrame, and a version that is the normal site. I do this through Master pages, and the site masterpage has many different content place holders than the framed version. For this reason I can't just swap the master page in and out. For example, http:/

Authorise part of a View IN ASP.NET MVC

不打扰是莪最后的温柔 提交于 2019-12-13 05:03:18
问题 I am currently using the [Authorise] attribute in Controllers to restrict Views to be only visible if the website user is logged in. But how do you restrict only part of a view? eg. Something like this...? <% if(SomeoneIsLoggedIn) { %> <div id="protectedContent">...</div> <% } %> This method is called when a login is successful: public static void CreateLoginCookie(User u) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(u.Id.ToString(), true, 9*60); string encryptedTicket =

Trigger Jquery Event after an onsubmit

回眸只為那壹抹淺笑 提交于 2019-12-13 04:44:05
问题 I would like to trigger a Div to open after a form completes an action. But I need to it only happen based on one particular action so it is specific. I'm not sure where to start. 回答1: Ok, so if a new page is not loaded after your form completes an action (i.e. you have submitted it), I would assume you mean you're not redirecting the user to a different page; you're just posting back the current "Cart" page with the updated data. So your question is, "How do I display content on my page only

getting error while download the file in mvc2

给你一囗甜甜゛ 提交于 2019-12-13 04:40:54
问题 In my site, i gave download option to download the file. when i am checking in local server it is working properly. But after deploy the server, if i click the link means it will show the following error, This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet. My code here public ActionResult Download(string fileName) { string pfn = Server.MapPath("~