ASP.net Articles

Nested Master Page Events not being called

Nested Master Page Events not being called This is the second time I've been caught out by this little feature, so I thought I'd geekzilla it for both reference and to help others. Scenario I'm a big fan of MasterPages and Themes as a design principle for web development, and

Paul Marshall - 2,552 views

Displaying XML just like Internet Explorer

Displaying XML just like Internet Explorer This is everything you need to display XML in your webpage the same way IE displays it when you open an XML document in IE. Html Register the js and place a literal where you'd like the XML to appear. <script src="

Paul Hayman - 8,356 views

Set Input Focus on a Control Programatically Added to an ASP.Net Page

Set Input Focus on a Control Programatically Added to an ASP.Net Page This little problem had the potential to drive me nuts for hours, I was fortunate to stumble over a blog with 100s of comments re problems of this nature and how to solve it. Most of the discussion was about using JavaScr

Paul Marshall - 3,817 views

Dynamically adding a CSS link to the page in c#

Dynamically adding a CSS link to the page in c# The following code adds a CSS link to the header node of a Html page. // register css HtmlHead head = (HtmlHead)Page.Header; HtmlLink link = new HtmlLink(); link.Attributes.Add("href",

Paul Hayman - 45,083 views

Preventing Caching of an ASP.net page in c#

Preventing Caching of an ASP.net page in c# The following code prevents a page being cached. public static void PreventCaching(HttpContext context) {     context.Response.Cache.SetExpires(DateTime.Now.Subtract(new TimeSpan(24,

Paul Hayman - 3,089 views

Getting the Virtual Path of a Request in c#

Getting the Virtual Path of a Request in c# This simple bit of code will get you the Virtual Path of your current request. public static string GetVirtualPath(string url) {     if (HttpContext.Current.Request.Application

Paul Hayman - 18,879 views

Fixing Form Action on UrlRewrite (UrlRewriter)

Fixing Form Action on UrlRewrite IF you're rewriting URL's, you've probably come across the same problem I had. When posting back on the page, the real URL is used.. this is a real pain if you're writing a page which uses the RawUrl to serve up relevant content. I had a good loo

Paul Hayman - 5,483 views

Custom Validators using Client Side JavaScript

Custom Validators using Client Side JavaScript In my latest project I am really enjoying using the Ajax Control Toolkit, particularly the ModalPopupExtender. I've been using the popup panels to capture data, but I needed to validate the data that a user enters into certain fields. ASP

Paul Marshall - 51,505 views

Creating your first ASP.NET AJAX 1.0 Application

Creating your first ASP.NET AJAX 1.0 Application Over the last year or so, AJAX has taken the web development world by storm. AJAX is short for Asynchronous JavaScript and XML and is an approach to building dynamic web applications that behave less like the static web pages we're used to and

Michael O'Brien - 4,842 views

Display CreateUserWizard Error Messages using a ContentTempate

CreateUserWizard Error Messages using a ContentTempate In our latest project we are implementing Membership, Roles and Profiles. I've used these before, but never really had the need to exploit all the features. The business requirements of the system have meant that I have had to imp

Paul Marshall - 8,437 views

Error connecting to undo manager of source file xxxx.aspx.designer.cs

Error connecting to undo manager of source file The Problem If you are using the Web Application Project Template (with as the Add On or as part of SP1) you can get this error. This error can simply appear at any time for no apparent reason. There have been several suggestions on th

Greg Duffield - 4,106 views

Returning a value from a PageMethod

Returning a value from a PageMethod using MS AJAX NOTE: This is designed for v1.0.61025.0 of AJAXExtensionsToolbox.dll If you've ever returned data from a web service using MS AJAX this technique will look familar. Call the method from javascript by append PageMethods. to the fro

Paul Hayman - 42,533 views

Getting the ProviderUserKey for the Current User

Getting the ProviderUserKey for the Current User The following gets the ProviderUserKey for the current user. (Guid)Membership.GetUser().ProviderUserKey

Paul Hayman - 3,737 views

Rendering a Control to a String

Rendering a Control to a String This is a really handy little function for rendering a control to a string. Really handy if you want to pass back rendered HTML from a StaticPageMethod or WebService. private static string GetRenderedControl(Control contr

Paul Hayman - 5,794 views

ASP.NET Framework 1.1 Validation not working in IE7?

ASP.NET Framework 1.1 Validation not working in IE7? I recently had a problem with an old Framework 1.1 website where the form would not post back if the page contained validators (CustomValidators to be exact). It caused me to do a lot of googling and in the end some javascript debugging.

Paul Hayman - 6,608 views

LoginStatus not logging users out?

LoginStatus not logging users out? Have you noticed your LoginStatus control doesn't log the user out when you click Logout? Well, to fix this all you need to do is add an id attribute. This works <asp:LoginStatus runat="server" id="loginstatus1" /> Thi

Paul Hayman - 6,930 views

XMLHTTPRequest in Stored Procedure

XMLHTTPRequest in Stored Procedure I recently had a requirement to call a webservice from a stored procedure. I looked into doing this by writing a CLR assembly in SQL 2005. There were a few articles online describing this but working in a large organisation I knew that getting the thi

Dave Howard - 20,769 views

Using a .Net 2.0 anonymous delegate when generating a thumbnail

Using a .Net 2.0 anonymous delegate when generating a thumbnail Rather than using a mehod which does nothing except return false. Use a .Net 2.0 anonymous delegate for the GetThumbnailImageAbort parameter. delegate() { return false; } Example System

Paul Hayman - 3,160 views

Json converters lacking in Microsoft AJAX RTM

Json converters lacking in Microsoft AJAX RTM Having spent some time developing a project using a CTP version of Microsoft Ajax ("ATLAS" back in the day) I finally came to migrate the project to the RTM version. After uninstalling the CTP release, and installing the RTM release I wasn

Dave Howard - 5,024 views

Handy fake latin generator

Handy fake latin generator 4guysfromrolla have a handy "fake latin" generator. It allows you to specify the number of paragraphs to generate. Source available too, although old asp. http://www.4guysfromrolla.com/demos/latin.asp?paras=2

Paul Hayman - 5,090 views

CAPTCHA Server Control

CAPTCHA Server Control I have been searching Google for a way to quickly implement CAPTCHA on one of my web sites and came across this article at The Code Project. http://www.codeproject.com/aspnet/CaptchaControl.asp

Barrington Haynes - 2,505 views

"This row already belongs to another table" Error

"This row already belongs to another table" Error What an annoying error!! I couldn't believe that I couldn't just add a Row from one DataTable to another, while looping around a DataTable's Rows. It turned out to be slightly more complicated than the code I had written, I've si

Paul Marshall - 141,002 views

Google Applicance - googleoff / googleon Tags

Google Applicance - googleoff / googleon Tags I came across these recently... thought I'd share The googleoff/googleon tags disable the indexing of a part of a web page. The result is that those pages do not appear in search results when users search for the tagged word or phrase. For

Paul Hayman - 53,085 views

Typed Masterpage reference

Typed Masterpage reference ASP.NET master pages are pretty handy and here is a simple tip to make them even easier to use. Using the MasterType reference in your content page allows you to refer to your master page properties without having to cast it to your master page type everytime.

Dave Howard - 9,662 views

Authenticated HTTPRequests (Using Credentials)

Authenticated HTTPRequests (Using Credentials) Recently I had to make a SOAP call to a Cisco CallManager (an IP PBX). This required that the request used basic authentication. I couldn't add a web reference as the cisco interface doesn't support GET requests, so the Visual Studio discovery

Dave Howard - 81,933 views

Lightweight Ajax

Lightweight Ajax Ajax doesn't have to be complicated - at its most basic it just means partial updates your pages rather than reloading the whole page. The attached js library contains just two functions - GetContent and RunJS. GetContent() takes a URL and a element name: It si

Dave Howard - 7,739 views

Web service calls from javascript using ATLAS (part 3) - Complex properties

Web service calls from javascript using ATLAS (part 3) - Complex properties Part two covered returning objects with multiple properties from a webservice and accessing those properties from javascript. This article demonstrates that even 'complex' properties are supported by the ATLAS

Dave Howard - 5,389 views

Web service calls from javascript using ATLAS (part 2) - Complex return types

Web service calls from javascript using ATLAS (part 2) - Complex return types Following on from part one which showed how to make web service calls from javscript, this article will now show the flexibility of the ATLAS framework by calling a web service that returns an object from jav

Dave Howard - 7,068 views

Web service calls from javascript using ATLAS (part 1)

Web service calls from javascript using ATLAS (part 1) ATLAS provides a fantastic mechanism for making web service calls from javascript code. Take the simple web service below... public class myWebService : System.Web.Services.WebServic

Dave Howard - 5,990 views

Not using Google Analytics? You should be!

Not using Google Analytics? You should be! Over the past few days I have received a number of comments regarding a recent article I published about re-directing a Page by Appending an HTTP Header, and linking this with Google's Analytics PPC tracking for Affiliate click-throughs. Read it he

Paul Marshall - 8,700 views

Auto-complete using ATLAS

Auto-complete using ATLAS Setting up an auto-complete input box in ATLAS is pretty simple, here is a quick guide to illustrate this... Assuming you already have the ATLAS framework referenced in your project then select an <asp:TextBox> to apply auto-complete to. See Mark

Dave Howard - 8,966 views

Creating a Tag Cloud in C#

Creating a Tag Cloud in C# I wanted to add a TagCloud to GeekZilla and another bespoke development project. The first thing I did was look around the web for some examples (or free components). To my supprise none jumped out at me. So, I decided to write my own. At first I found myself

Paul Hayman - 76,579 views

Custom Templated SiteMap Navigator Control

Custom Templated SiteMap Navigator Control After discovering the power of the SiteMap, especially when linked to Authentication, it wasn't long before binding the TreeView to the map was not enough. I needed to have total control over what was displayed to the user for each item, so I

Paul Hayman - 6,273 views

Redirect a page using a Header

Redirect a page using a Header Any keen surfer will be familiar with Affiliate Marketing, its a huge industry with Google's Adwords driving "Pay Per Click" campaigns. Google provide the Adwords application and Google Analytics to track the effectiveness of marketing campaigns from click thr

Paul Marshall - 16,286 views

Sending mail using Localhost and .Net 2

Sending mail using Localhost and .Net 2 I came across an old favourite today when trying to send email using the SMTP service on Local host. The error was SMTP 550 5.7.1 Unable to relay for xxxxxx What you need to do is change the security settings on the SMTP Service to allow

Greg Duffield - 3,749 views

Comparing ATLAS and Dojo (part 1)

Comparing ATLAS and Dojo (part 1) This is a first article in a series comparing some of the functionality of ATLAS with another popular AJAX framework called Dojo. Both frameworks have some powerfull components and there is a high degree of overlap. This first article is a straight com

Mark Page - 12,911 views

Programmatically adding LINKs to HTML HEADER in Code Behind

Programmatically adding LINKs to HTML HEADER in Code Behind In this example I am adding a link to the html header pointing to an rss feed. HtmlLink link = new HtmlLink(); link.Attributes.Add("type", "application/rss+xml"); link.Attributes.Add("rel",&

Paul Hayman - 13,332 views

Return new identity from Strongly Typed Dataset DataTable.Insert method

Return new identity from Strongly Typed Dataset DataTable.Insert method Datasets are pretty good at auto generating stored procedures and wrapping c# code around them for you. However with the insert method you often want to do something with the object that you have just inserte

Dave Howard - 26,796 views

TraceListener creates huge log files

TraceListener creates huge log files If you've used the .Net trace listeners, you'll know that they just keep appending to the file specified in the App.Config file, this can lead to some massive log files! Here's a simple TraceListener that logs to a new file for every day.

Lee Keable - 11,805 views

Integrating Dojo Fisheye and SiteMapDataSource

Integrating Dojo Fisheye and SiteMapDataSource Everybody seems to be getting excited over this AJAX thing. Even Microsoft are (at last... ok they started it with OWA) getting on the bandwagon with the Atlas libraries. Of course just because Atlas exists doesn't mean you cannot use some

Mark Page - 13,862 views

Extending web.sitemap

Extending web.sitemap If you are using ASP.NET you are probably already familiar with the new sitemap components. The sitemapdatasource and web.sitemap elements make it very easy to build and maintain rich site structures. Using the Eval statement and recursing across the siteMap

Mark Page - 10,930 views

Extending Strongly Typed Datasets

Extending Strongly Typed Datasets Strongly Typed Datasets are a rather nice addition to VS2005 (they don't lend themselves well to acronyms however) You still need to create a database and tables and realationships but using STDs saves a writing huge amount of code. If this code

Dave Howard - 6,301 views

Serializing abstract classes to XML

Serializing abstract classes to XML Digg it: http://digg.com/programming/Serializing_abstract_classes_to_XML_in_c It is often useful to have abstract classes with several derived types to allow use of strongly typed lists and the such. For example you might have a DocumentFragmen

Dave Howard - 23,778 views

Parser Error Message: Ambiguous match found.

Parser Error Message: Ambiguous match found. VS 2005 Only. This can be an annoying error, but it is usually caused by one thing. If you add an object to your html source such as <igtxt:WebDateTimeEdit id="dteStartdate" runat="server" ToolTip="The end Date

Greg Duffield - 16,269 views

Strongly Typed DataSets and GridViews

Strongly Typed DataSets and GridViews If you are anything like me you don't enjoy writing 5 or 6 stored procedures for each business object in your solution. If you do, then click here to read more about T-SQL! http://www.geekzilla.co.uk/Browse.aspx?CategoryID=32 For the re

Dave Howard - 9,744 views

Could not write to output file ... The directory name is invalid

Could not write to output file ... The directory name is invalid Recently had a problem deploying an app to a fresh 2003 server. Basically, the application wouldn't start, instead we recieved an error stating that the compiler couldn't write to the "Temporary ASP.NET Files" folder because th

Paul Hayman - 17,062 views

Intellisence not working in web.config?

Intellisence not working in web.config? Visual Studio 2005 has an interesting "feature" where Intellisence will not pop up when you're editing a web.config file. Annoying eh? Well, I found that removing the namespace from the configuration tag kicks it all back into life. Change the fo

Paul Hayman - 3,784 views

Changing the password rules for Forms Authentication

Changing the password rules for Forms Authentication An annoying feature of the forms authentication controls shipped with VS2005 is that it forces users to enter non-alphanumberic characters in their passwords by default.. e.g. password would have to be password! Fortunately, this opt

Paul Hayman - 4,716 views

Stopping simultaneous logins (Forms Authentication)

Stopping simultaneous logins (Forms Authentication) The following code (called from a page load) will bump off users who are logged in when someone else logs in with the same credentials. publi

Paul Hayman - 5,644 views

Enabling HttpGet and HttpPost for web services

Enabling HttpGet and HttpPost for web services If your web application needs to accept incoming webservice method requests based on the GET and POST protocols then add the following lines to your web.config file. <configuration>   <system.web>

Barrington Haynes - 9,762 views

EasyHTTP

EasyHTTP EasyHTTP is a simple class which exposes the HTTP functionality of .NET as a number of simpler methods.

Barrington Haynes - 6,318 views

Updating Foreign keys in a GridView

Updating Foreign keys in a GridView A GridView generally shows and allows the user to update rows in a database. They are easy to set up until the values that you want to update is a foreign key. Its not obvious how to send the appropriate value back to the database or how to

Dave Howard - 12,311 views

Garmin and Google Maps

Garmin and Google Maps The bought a Garmin Forerunner recently which is a really cool piece of kit but the maps that come with it are very poor. Google maps has an API that allows you to integrate these rich maps into your own web applications. Garmin has the option to export yo

Dave Howard - 13,472 views

Missing VS2005 Templates

Missing VS2005 Templates If you are having problems with missing VS2005 templates, then the following command run from the VS2005 command prompt may resolve your problems. devenv /installvstemplates

Barrington Haynes - 4,656 views

Perform actions before a row is deleted from a GridView or a DetailsView

Perform actions before a row is deleted from a GridView or a DetailsView I'm a big fan of caching objects on the web server, really saves loads of unneccessary trips to SQL Server and those precious resources. In a recent project I built some administration screens to change the con

Paul Marshall - 8,264 views

Select a row in an asp:GridView without using a Select Command

Select a row in an asp:GridView without using a Select Command ASP.Net's GridViews can be quite useful, but beware of binding them to huge datasets as this has an overhead on the ViewState. Often you'll want to display a number of columns on each line and row space becomes an issue. W

Paul Marshall - 489,550 views

Error in Line 3?

Error in line 3 Some websites report an error in line 3 when using the asp.net controls such as login. We recently tracked this error down on one of our sites to the use of custom HttpHandlers. All requests to anything other than *.aspx were routing through our own handler.. Addi

Paul Hayman - 3,757 views