ASP.NET News from Blogger: mikes web log   Get the feed of: mikes web log

Total News: 165

"Remembering" a selection in a <select> list in Razor

I'm just recording this for now, possibly for later investigation. In ASP.NET Web Pages 2 (Razor), you can take advantage of conditional attributes to set or clear attributes like selected and checked...

Login redirection (and back) in ASP.NET Web Pages Razor

When you use membership security in ASP.NET Web Pages Razor, you can limit access to pages so that only logged-in users can see those pages. One way to do that, as explained before, is to add a test l...

Razor tip: Escaping the "@" character

In ASP.NET Web Pages/Razor, you use the @ character inside markup to mean "here be code." Like this:<p>@DateTime.Now</p>But suppose you want to display the @ character instead of use it ...

"Page" vs "PageData" objects in ASP.NET Web Pages

I was playing around with layout pages in ASP.NET Web Pages the other day and realized that there are actually two ways to pass data from the content page to the layout page: the Page object and the P...

Two small ASP.NET Web Pages (Razor) syntax tips

Two tips for Razor syntax: using a conditional attribute to set the selected attribute in a list item; working around a syntax restriction on x@x (e.g. <h@level>).Tip 1When I wrote recently abou...

Whitepaper on ASP.NET 4 security extensibility

Just a note that we just posted a whitepaper [PDF] written by the super-smart Stefan Schakow that discusses various ways in which ASP.NET 4 lets you extend security. For example, the paper descri...

Full list of new features for ASP.NET Web Pages v2 Beta

Ok, we've now got a list of the new features for ASP.NET Web Pages v2 posted. Here's a list of the stuff that's been added since the December 2011 preview, as recounted in the updated Top Features doc...

New for ASP.NET Web Pages: Better ~ operator support

Another improvement in the Beta release of ASP.NET Web Pages v2 is better integration of the ~ operator. The ~ operator, as ASP.NET people know, resolves to the root path of the current website. (See ...

New for ASP.NET Web Pages: Conditional attributes

The beta release of ASP.NET Web Pages has been released (for example, as part of the ASP.NET MVC 4 Beta release). There are only a few differences from the December 2011 Developer Preview release...

Updated validation in Web Pages v2, Part 3

As noted previously, to display validation errors in ASP.NET Web Pages v2, you can use Html.ValidationMessage and Html.ValidationSummary. You can use one or the other or both. If you use both, one ide...

Updated validation in Web Pages v2, Part 2

In the last post, I laid out the basics of the Validation helper that's introduced in ASP.NET Web Pages v2. As I noted then, the helper supports both server- and client-side validation. Here's how to ...

Updated validation in Web Pages v2

In v1 of ASP.NET Web Pages, you could add user-input validation by doing something like this in code:if (name.IsEmpty()) {    ModelState.AddError("Name", "You must enter a name....

WebMatrix and ASP.NET Web Pages books

We're quite happy to see a number of books about WebMatrix and ASP.NET Web Pages become available. Here is the list of books that I'm aware of at the moment:Beginning ASP.NET Web Pages with WebMatrixM...

Horizontal menu as a Razor helper

On the forums, someone was asking about creating a horizontal menu using Razor code in ASP.NET Web Pages. The technique of combining an unordered list (<ul> element) with CSS to create a horizon...

Need feedback: draft article about request validation

A couple of us on the ASP.NET documentation team are working on a topic that describes how to disable request validation in ASP.NET. What do you think about the following draft? Any feedback welcome.R...

Getting custom info from the FileUpload helper

In ASP.NET Web Pages, you can use the FileUpload helper[1] to render HTML that lets user upload one or more files. For example, this helper:@FileUpload.GetHtml( initialNumberOfFiles: 1, allowMor...

MembershipProvider error in ASP.NET Web Pages

If you use membership in ASP.NET Web Pages, you might get the error "To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider":I happened to run ...

Installing version 1 of WebMatrix after installing WM2 beta

The beta version of WebMatrix 2 was put out for public consumption around the time of the //build/ conference in September. Very nice.However, installing WebMatrix 2 beta makes it harder to ...

Deploying Web Pages applications without a tool

The canonical way to deploy a Web Pages application to a remote server is to use the Publish facility of WebMatrix. (Or the publish facilities in Visual Studio, if that's what you're using.) Using a p...

Using Windows authentication in ASP.NET Web Pages

When I wrote about using simple membership in ASP.NET Web Pages a little while ago, commenter akshayms asked "How can I use Windows authentication"? Simple membership uses a login form and a members...

Componentizing code in WebMatrix pages

At first glance, you might thing that in WebMatrix Razor (.cshtml, .vbhtml files) you have to put all your code into the page. For example, if you sift through pages created by the Starter Site templ...

"Potentially Dangerous" errors in ASP.NET Web Pages (Razor)

By default, ASP.NET performs request validation to prevent people from uploading HTML markup or script to your site. If someone includes markup in a page that they post to your site, ASP.NET throws a ...

Constructing site URLs in ASP.NET Razor

The other day I showed how to send a confirmation email when people register on your site. In the example, I created a link that points to a confirmation page on my site, and I hard-coded the URL of t...

TOC, TOC, who's there?

Most of what we write is published in the MSDN Library, which has documentation of all sorts for developers (the D in MSDN) who use the Microsoft platform. A recent estimate is that there are about 2....

Using the confirmation feature for ASP.NET Web Pages security

When I described the most basic way to implement security (membership) for ASP.NET Web Pages/Razor websites, I skipped over a feature that you can add to the registration page — namely, confirma...

The absolutely most basic way to implement security in ASP.NET Razor

If you look at the ASP.NET Web Pages (aka Razor) tutorials on the ASP.NET web site, there's a chapter devoted to adding security to a site in the form of membership (that is, a login capability). This...

Keystroke mappings in WebMatrix

Most of the keystrokes you can use in WebMatrix are pretty familiar Ctrl+C/Ctrl+V to copy/paste, of course, plus Ctrl+F4 to close a tabbed doc, plus F3 for search. But there are a few that are not as...

WebMatrix/Razor Beta 3 updates

The Beta 3 release of WebMatrix and ASP.NET Razor went out last Tuesday, and there are a couple of things in the release that are updates to something I've noted before. Setting Editor OptionsOne upda...

ASP.NET Razor Chart helper: What chart types can you use?

The ASP.NET Chart helper displays charts, as you can read in the chapter Displaying Data in a Chart:For purposes of the Chart helper, you specify the chart type (bar, line, area, etc.) by passing the ...

Renaming SQL tables in WebMatrix (run SQL commands)

Here's a tip that came up on an internal alias today. When you create a database table in WebMatrix, you click the New Table button in the ribbon, define your fields, and then save. The save process g...

Rendering HTML <em>as</em> HTML in Razor

Suppose you want to concat together a bunch of strings and markup, maybe like this:var stringWithMarkup = "a" + "<br/>" + "b" + "<br/>" + "c" ;(Let's assume you're doing somethin...

Dude, where's my Razor API ref?

I noted last time that we approached the documentation for WebMatrix and ASP.NET Web page (Razor) a bit differently. This was in part due to the target audience — Razor is aimed at folks who ar...

Documenting ASP.NET Razor

One of the design principles of WebMatrix and of ASP.NET Razor syntax is to keep things simple and friendly. Among the ways in which this is implemented in the UI, for example, is to focus on only the...

WebMatrix tip: 403.14 and 404.8 errors

One of the more startling things that can happen when you first start to work with WebMatrix is that you'll be editing a page, click Run, and then see the error HTTP Error 403.14 - ForbiddenThe Web se...

WebMatrix Beta 2 tip: why can't I use helpers?

Here's the first of a couple of tips that are gleaned from the WebMatrix/ASP.NET Razor Beta 2 readme file. But who reads the readme? :-)Tip: Helpers don't work in Beta 2 until you install them. Helper...

WebMatrix and ASP.NET Razor

By now you'll probably know that we released (in beta) a new version, I guess you'd call it, of ASP.NET. It's not really a new version -- same old ASP.NET behind the scenes -- just a new and simpler s...

Out, damned space

The other day I was doing something where I wanted to display some data as a comma-delimited list, like so:a, b, c, dThis seemed like a job for the Repeater control. So I created the markup for the co...

New template for ASP.NET Web site projects

Visual Web Developer has long had a blank-sheet-of-paper issue when you create a new Web site project or Web application project in Visual Studio. As in, you create the project and then you, developer...

New location (and look) for ASP.NET documentation

ASP.NET documemntation actually has a couple of homes. There's the grab-bag of articles, tutorials, and videos about ASP.NET that's posted on the http://asp.net site. And the official documentation --...

If you can't say something nice ...

At work, we write documentation for programmers, so our docs include many code examples[1]. We should comment our code, right? Of course. However, a discussion broke out in our ranks yesterday about t...

Why <i>not</i> link to Wikipedia?

An issue that has come up a number of times at work is the question of linking to articles in Wikipedia. It's not terribly unusual for us to link from the documentation set to non-Microsoft resources....

My poor memory for old technology

I've been in this industry a long time. This doesn't make me smart, just ... old. Being old, I find that my memory just isn't what it once was (which wasn't much). So for example ...A little while ago...

Docs for creating custom controls

This is a question about the documentation on MSDN. There's a section on how to create custom ASP.NET controls, which starts at Developing Custom ASP.NET Server Controls:We're looking at maybe updatin...

Can you use Web Forms controls with MVC?

As more people delve into ASP.NET MVC, we see more questions from people who are used to the Web Forms model and are curious where these technologies overlap. We have noted in the docs that views can ...

When do you use Design view?

At PDC2008, Jeff King demonstrated features and improvements that his team is proposing for the next release Visual Web Developer. Among them are lots of tweaks to HTML editing. This got me thinking a...

How I broke my app with UpdatePanel controls

As with so many things, it also started out so simple. I wanted to use UpdatePanel controls to throw a little AJAX-ification onto one of my blog management pages. (Specifically, the blog entry page.) ...

Lack of practice makes imperfect

Apparently it's been too long since I've played with SQL Server databases. I say this because I made a boneheaded mistake today that obliged me to spend some quality time in the debugger. Someone aske...

Stack Overflow and developer documentation

Stack Overflow, the much-anticipated project put together by Jeff Atwood and Joel Spolsky, went live a couple of days ago. The site brings the known vectors for crowdsourcing to developer documentatio...

Docs, undocumentation, and the DailyWTF

An ignominious appearance on the DailyWTF recently got one of our documentation topics some undue attention. Alas. The topic in question pertains to what around here we call an "internal only" type ...

Tag cloud control

I recently decided to implement a tag cloud. I'm not quite sure why this grabbed me; I don't pay that much attention to them my own self. But the idea of how to do it interested me, so I gave it a bas...

View Other bloggers