Archive

Archive for the ‘ASP’ Category

Inline Asp.Net Markup Tags

February 9th, 2012 No comments

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.

http://msdn.microsoft.com/en-us/library/6dwsdcf5(v=vs.100).aspx

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>") %>
http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx

Data-Binding (<%# … %>)

Those are resolved when the DataBind method of the control or the page is called.

http://msdn.microsoft.com/en-us/library/ms178366.aspx

Server-Side Comments (<%– … –%>)

Used to comment out code/controls which then won’t be processed.

http://msdn.microsoft.com/en-us/library/3207d0e3.aspx

Server-Side Includes (<!– #include file|virtual=”filename” –>)

Used to insert to content of a given file within the current position.

http://msdn.microsoft.com/en-us/library/4acf8afk.aspx

Embedded Code Blocks (<% … %>)

Used to run some code without returning anything.

http://msdn.microsoft.com/en-us/library/ms178135(v=vs.100).aspx

Expressions (<%$ … %>)

Used for expressions instead of code.

http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx

Directives (<%@ … %>)

Specifies settings for the page or imports and such.

http://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx

Ad
Categories: ASP, Programming Tags:

Razor Template Engine

November 23rd, 2011 No comments

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 RazorEngine.
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

Exception.
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:
Just call

bool loaded = typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly != null;

before using

Razor.Parse

and you should be ready to go.

Ad
Categories: ASP, C#, Programming Tags:

ASP.NET Postback to new Window or Popup

August 23rd, 2011 No comments

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!
Read more…

Ad
Categories: ASP, HTML / CSS Tags:

Prevent automatically generated IDs for controls

March 15th, 2011 No comments

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

myHeadControl.Controls.Add(myHtmlMetaControl)

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.

Read more…

Disable Autocomplete in Firefox with ASP

October 15th, 2009 No comments

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:

Textbox1.Attributes.Add("autocomplete", "off");
Categories: ASP, Programming Tags:

WCF Service on IIS7

May 15th, 2009 No comments

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:

  1. Start the command window (cmd) as an Administrator.
  2. Navigate to:
    C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\
  3. In case you are running on a 64Bit machine, than navigate to:
    C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation\
  4. Run the following Command: ServiceModelReg –i

You now should be able to access your Webservice.

Categories: ASP, Programming Tags: , , , ,

How to disable the Asp.Net Debugging Timeout

April 1st, 2009 No comments

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.

Categories: ASP, Programming Tags: , ,

FindControl in Controls mit IDs

August 12th, 2008 No comments

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…

Postback Event Processing Sequence

August 6th, 2008 No comments

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…