Those tags are evaluated during the Render part of the page’s load cycle. See here for more information.
Displaying (<%= … %>)
Displays the given value as a string.
Displaying with Encoding (<%: … %>)
Displays the given value as string but HTML-Encodes it before.
If you’re sure that the given string is already html-encoded, use it like this:
<%: new HtmlString("<strong>HTML that is not encoded</strong>") %>
Data-Binding (<%# … %>)
Those are resolved when the DataBind method of the control or the page is called.
Server-Side Comments (<%– … –%>)
Used to comment out code/controls which then won’t be processed.
Server-Side Includes (<!– #include file|virtual=”filename” –>)
Used to insert to content of a given file within the current position.
Embedded Code Blocks (<% … %>)
Used to run some code without returning anything.
Expressions (<%$ … %>)
Used for expressions instead of code.
Directives (<%@ … %>)
Specifies settings for the page or imports and such.
We started using the Razor View Engine from Microsoft in preparation to switch to MVC 4 sooner or later.
Here are some introductory links:
Introduction to Razor Syntax
Quick Syntax Reference
There is an small OpenSource Engine which uses the Razor Parsing from the MVC Framework. This Engine is called
It is available from two sources, development continues on GitHub but the version there is currently very unstable.
Here are the links:
http://razorengine.codeplex.com (2.x, stable)
https://github.com/Antaris/RazorEngine (3+, early version)
While using the Version 2.1, I got an
Predefined type ‘Microsoft.CSharp.RuntimeBinder.Binder’ is not defined or imported
This seems to be a bug with Version 2.1, here’s the Discussion about it.
Actually there’s a really small workaround for it:
bool loaded = typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly != null;
and you should be ready to go.
Previously I thought this was not possible, since the ASP.NET postback involves POST-ing the all-encompassing ASP.NET form, but I am here to tell you, that it is indeed possible to do a postback to a new window or even a popup (created with window.open). In fact, it is surprisingly simple. All you really have to know is that the “target” attribute you know from anchors (links) works exactly the same way for forms!
Today I’ve had an extremely interesting realization: the number, order and exact point in the page lifecycle at which HtmlMeta controls are added to the HTML head can have significant implications for your page. Especially if you have some sort of “transient” meta tags that are only added to the page when it is initially loaded, but not after a postback. When you call the
method, every control that doesn’t have a manually set ID will be assigned an automatic ID by its naming container (ctl00, ctl01, …). This doesn’t seem too bad until you realize that this means that the ID of your very important custom control can change from “…ctl08…” during initial page load to “…ctl04…” in a postback. And THAT is a problem. Because the way that the view state is restored to the control tree is directly through those control IDs. Actual results can vary from mismatched control values to view state exceptions and lots of other hard-to-trace problems.
When using a AutoCompleteExtender from the AjaxToolkit, Firefox may show it’s own AutoComplete List over the one you want. To disable that, you need to disable autocomplete on the Field or the entire Form.
To do that, just add an
autocomplete="off" to the Textbox in the Markup Code or add the Attribute on Runtime like this:
When you try to access a WCF-Service with your Browser you might see the following Error:
HTTP Error 404.3 – Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
If that happens, you probably don’t have the Service Model registered with your IIS.
Here’s how to register it:
- Start the command window (cmd) as an Administrator.
- Navigate to:
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\
- In case you are running on a 64Bit machine, than navigate to:
C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation\
- Run the following Command: ServiceModelReg –i
You now should be able to access your Webservice.
When developing Web-Applications with Asp.Net, you often run the Page with your Debugger and want to step thru the Code. If you hold too long on a line (default is 90 Seconds) you’ll get a Timeout and the Debugging stopps.
Here’s how you can disable that the Debugger stopps:
- Open the IIS Manager
- Go to the Application Pools
- Right-Click your Application Pool and select “Advanced Settings…”
- Search the Setting “Ping Enabled” under “Process Model”
- Set it to “false”
- Press Ok
- If you get an “insufficient permissions” Error or something, try to clear the “Read only” Flag from that File you see in the error Message.
That’s it. You can now debug as long as you want without getting a Timeout.
Wer schon mit dem AjaxToolkit gearbeitet hat kennt das Prinzip der Extender. Dabei werden dem Extender jeweils die ClientIDs der Controls mitgegeben, die entsprechend erweitert werden sollen. Der Extender kann dann über Page.FindControl das ensprechende Control finden es entsprechend anpassen. So weit so gut, doch was tun, wenn nun dieser Extender in einem Repeater ist? Read more…
ASP is pretty much Event-Oriented. So it’s important to know the exact Sequence of the Events for a Page-Life-Cycle.
Here’s the List (in sequence): Read more…