webforms

ASP.NET Repeater Template, Conditional Code for every Nth element

十年热恋 提交于 2020-01-01 04:19:35
问题 I'm using an asp.net repeater to create a bunch of images. The image markup is all the same so the standard <ItemTemplate> is fine. However, I want to wrap K images in a div. Lets say I bind 25+ images to the repeater and I want 5 images per div. How do I go about conditionally creating the start and close tags for the div? Is this a case better suited for a for loop. 回答1: This should work for you, with no need for anything in the code behind (other than binding the repeater..): <asp:Repeater

Export a list of LINQ objects to Excel file

假如想象 提交于 2020-01-01 03:32:06
问题 From a web application, is there a simple way to export a list of LINQ objects to an Excel file? Are there any good libraries that can do this? 回答1: So, in specifying Excel, you're committing to a row / column paradigm (as opposed to xml, for example). So you'll have to specify how the properties map to columns. Beyond that you write to an Excel file using the Ole DB provider. Loop through your objects, generating an INSERT statement for each one using a stringbuilder, and execute that

Ninject with ASP.Net webforms and MVC

人盡茶涼 提交于 2020-01-01 03:13:08
问题 I want to use Ninject in a project which combines ASP.Net webforms and ASP.Net MVC. I'm using Ninject 2, but when I use NinjectHttpApplication from Ninject.Web.Mvc it complains when I use somethings like a PageBase that the Kernel is not created. I have the following in the Global.asax and am unsure what to add. public class MvcApplication : Ninject.Web.Mvc.NinjectHttpApplication { protected override void OnApplicationStarted() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable

Things I cannot do in ASP.NET MVC

社会主义新天地 提交于 2020-01-01 02:29:32
问题 Are there some things I cannot do with ASP.NET MVC? Things that are only possible with ASP.NET WebForms, or extremely much easier with WebForms? We consider using ASP.NET MVC for a new project. But I wonder if there are some obvious things we will not be able to do with ASP.NET MVC when compared to WebForms, or places where we will have to spend a lot of time with ASP.NET MVC. 回答1: The biggest one would be using existing 3rd party controls on your form. Most of the inbuilt controls are pretty

Content-Security-Policy in ASP.NET WebForms

╄→尐↘猪︶ㄣ 提交于 2020-01-01 01:33:08
问题 I'm looking for a good way to implement a relatively strong Content-Security-Policy header for my ASP.NET WebForms application. I'm storing as much JavaScript as possible in files instead of inline, but by default, WebForms injects a lot of inline script for things as simple as form submission and basic AJAX calls. MVC has some simple ways to implement nonces, especially with the help of third party libraries like NWebsec, but I can't seem to find any methods of implementing them with

Turning off the WebFormViewEngine when using razor?

不问归期 提交于 2019-12-31 08:41:47
问题 I downloaded Glimpse this morning to try it out and noticed this when I click on the views tab: It checks all of the loaded view engines. I found where the RazorViewEngine is specified in web.config, but I couldn't find where the WebFormViewEngine was. Since I know my project will never have an web form view in it, Is it ok/safe to turn off WebFormViewEngine ? How can I turn off WebFormViewEngine ? 回答1: It is perfectly OK to remove the web forms view engine if you are not using it. You can do

Can a web server dynamically generate an executable on the fly?

淺唱寂寞╮ 提交于 2019-12-31 05:28:15
问题 Ninite.com seems to be doing it currently. I'm wondering how. While it's possible for them to have every combination of app pre-generated, it seems unlikely/hacky. [EDIT] Is compiling a Windows executable using this method resource-intensive? Can it be done ~100k times a day without exorbitant cost? I'm asking because Ninite announced that they're going paid-only... can it be costing them that much? [EDIT2] The downloads aren't huge, it's just a small hundred KB web-based downloader+installer

How to generate a path/url from a Route in the Routes table?

江枫思渺然 提交于 2019-12-31 05:25:18
问题 I have an ASP.NET MVC web application, and I've registered a number of routes in my Global.asax. I would like to know how I can programmatically build (generate a string url) any one of those registered routes from within my Controller. I did the same thing in Web Forms with .NET 4.0 using Page.GetRouteUrl(routeName, routeParams) but can't figure out how to do the same thing in MVC (I'm an MVC newbie). 回答1: You could use the UrlHelper class inside your controller action. public ActionResult

Is it possible to do a cross page POST to an ASP.NET, from a static HTML form?

心不动则不痛 提交于 2019-12-31 04:29:07
问题 I am trying to create a static HTML page which has a <form> which posts to a 3rd-party ASP.NET website. Is this possible when the target website uses ASP.NET webforms? 回答1: This is absolutely possible. You can issue a POST to any website, anywhere. (Keep this in mind when you're designing an application that accepts POSTs from a web merchant such as PayPal ;-) make sure you know where the POST is coming from.) Whether or not the website will accept your request, of course, is up to however

Disallow typing of few of characters e.g.'<', '>' in all input textboxes using jquery

拥有回忆 提交于 2019-12-31 04:07:32
问题 How do I achieve this:- When user types character like 'abcd' and then '>' (an invalid character for my application), I want to set the text back to 'abcd' . Better if we can cancel the input itself as we do in winforms application. This should happen when user is typing and not on a click of button. I want this to be applied on all text boxes in my web page. This will be easy if the solution is jQuery based. May be something which will start like this. $("input[type='text']") SOLUTION I used