ASP.Net

Unexpected calls to default.aspx page_load ?

I had a bizzare problem. From a completely unrelated aspx page I was finding myself jumping into the page_load of my default.aspx page.

Turns out this was because I had an ‘<asp:image’ tag with the image url not set (rendered as src=””).

Tricky problem to identify.


Firefox refresh page retaining checkbox/radiobutton values

I had a page which uses codebehind Page_Load and (!IsPostBack) to setup all the controls on the page depending on what was being loaded. This worked fine, apart from when I refreshed the page (F5) in Firefox 3.5 – IE was okay.

Firefox seems to retain all the input selections – eventhough from the code behind I was ressetting them.

The only way I found to resolve this was to call a reset on the form (actually in my Master page) in the document ready function of JQuery which solves the problem.

$(document).ready(function() {

$(“#<%= (form1.ClientID) %>”)[0].reset();

});


Problem with ASP.Net & Radiobuttons in repeaters/datalists/datagrids all being selectable

RadioButtons place on a page inside a repeating control (repeater/datalist/datagrid), you set the group but they are still all individually selectable.

I have come across this problem before, which was fixed using some client side script added to the radiobuttons, but this had to be done for each radiobutton group as I added them and was a bit of a pain.

I have recently found a much better solution here -> http://www.codeproject.com/KB/webforms/How_group_RButtons.aspx

Works perfectly well. Unstructions:

1) Just download the zip file at the top of the page.

2) Unzip and place the file (GroupRadioButton.dll) into your bin folder.

3) Add a reference to the assembly into your web.config or .aspx page as below:

<%@ Register TagPrefix=”vs” Namespace=”Vladsm.Web.UI.WebControls” Assembly=”GroupRadioButton” %>

Use the control on your page as you would a RadioButton

<vs:GroupRadioButton id=”MyRbn” runat=”server” GroupName=”MyRbnGrp” />

Thats it. Brilliant 🙂

Kudos to Vladimir Smirnov.


ASP.Net UpdatePanel breaks Javascript/JQuery e.g. Slimbox, Tooltip...

After using ASP.Net Ajax components such as an updatepanel on your page you may see that some of your Javascript/JQuery functions do not seem to work once a partial page update has been done. This is because thanks to the partial page update those items contained within it have been reloaded but no functions have been rebound to them.

I have used 2 solutions for this, one is JQuery Live Query. You can use this to simply rebind to any item reloaded for example I used this to rebind the elements I had previously set for Slimbox and set the rel=lightbox attribute for them:

$(“a[rel^=’lightbox’]”).livequery(function() {
$(this).slimbox();
});

This finds any anchor element with the rel=”lightbox” tag and binds the slimbox function.

Alternativly to this you can replace the

‘$(document).ready(function() {

// do stuff

});

with

function pageLoad(sender, args)
{
// do stuff

if (args.get_isPartialLoad())
{
//Specific code for partial postbacks can go in here.
}
}

But be aware this can only be used once on the document, if you need to do this in multiple places use:

Sys.Application.add_load(function() {

// do stuff

});


Visual Studio - Attach to running local web site process to debug (and cannot see w3wp.exe?)

I had this problem where I wanted to attach my Visual Studio debugger to and already running website on local host.

From a bit of Googleing I found the process I needed to attach to was the IIS worker process called w3wp.exe, but this was not in my list. I noticed if I refreshed the site and then looked quickly in the process list it was there but then dissapeared shortly after – so a timeout I guessed.

This is what was happening, so I needed to stop it from timing out or at least delay it.

The answer was to change a setting in the applicaiton pool – ‘Shutdown Time Limit’.

Solution Summary:
– Goto IIS and find the website or application you want to modify.
– Click advanced settings to find the applicaiton pool it is using (or as I did create a new application pool and assign this website to use it)
– Goto your application pool list – selected advanced settings
– Change the ‘Shutdown Time Limit’ to something like 1000 (seconds) its default is 90

w3wp.exe should now hang around long enough to attach to it with the debugger 🙂


« Newer EntriesOlder Entries »