ASP.NET 2 LoginView Inside FormView Data Binding Problem

I was recently working on an ASP.NET 2 application which uses the SQL Membership Provider for User Role Management.  While customising the output of the forms in the admin area using the LoginView I encountered a bug in asp.net 2.  This bug wasted a lot of time debugging and scratching my head wondering what was wrong.

For some reason all the controls that I had moved into a LoginView were no longer binding to the DataSource used by the FormView.  I spent a lot of time looking for an answer on Google and the only post I could find about this problem is:

LoginView not showing databound controls
http://social.expression.microsoft.com/Forums/en-US/web/thread/676ca185-6ff6-4419-b79b-102cbd1a7314/

This post identifies the problem occurs when an edit, delete or insert operation is performed on the FormView.

This led to to my work around for the problem:

Instead of using the command buttons provided by the FormView to change its mode I replaced the form view command buttons with standard buttons with the following code behind:

Protected Sub EditButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim strURL As String = “EditScript.aspx”
   
If Request.QueryString(“sid”) <> “” Then
     
strURL &= “?sid=” & Request.QueryString(“sid”) & “&method=edit”
   
End If
    Response.Redirect(strURL)
End Sub

Instead of just changing the FormViews CurrentMode the button handler redirects to the script with a couple of query string parameters to tell the form what behaviour is required.

The page_load event then checks these query strings and modifies the FormView accordingly, when using this method to change the FormViews mode the databndings will display the data bound to them inside the LoginView controls.

Because the two-way binding is also affected for controls inside the LoginView, the next step is to intercept the FormViews updating, inserting, deleting events etc to load the value from the LoginViews into the DataSources parameters.

I haven’t had time to experiment with alternatives such as changing the FormView.CurrentMode in the handler instead of redirecting but if anyone knows of a neater solution then please post comments.

If you need code samples for the rest of my work around then please let me know.

January 23rd, 2009 | Leave a Comment

Free Flash Charting Control for ASP.NET, PHP and More

I have recently been working on a management dashboard for an e-commerce website and needed a good charting control to display an overview of sales, registrations etc.

After a brief crawl on the web I came across Fusion Charts. The controls are as neat and easy to use as any of the premium solutions I could find, but best of all, the basic package is completely free, even for commercial use.

The free version of Fusion Charts is not lacking in functionality either, with a huge range of charts and good examples of code for multiple platforms you will be suprised how quickly you can get a really professional and useful chart integrated with your application. Below is a simple example of Fusion Charts in action:

Integration of the charts is as simple as copying the chart folder to the root of your application, creating the required xml data then embedding your chart in your html page. A sample of the xml data can be seen below:

<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showNames='1' decimalPrecision='0' formatNumberScale='0'>
<set name='Jan' value='462' color='AFD8F8' />
<set name='Feb' value='857' color='F6BD0F' />
<set name='Mar' value='671' color='8BBA00' />
<set name='Apr' value='494' color='FF8E46' />
<set name='May' value='761' color='008E8E' />
<set name='Jun' value='960' color='D64646' />
<set name='Jul' value='629' color='8E468E' />
<set name='Aug' value='622' color='588526' />
<set name='Sep' value='376' color='B3AA00' />
<set name='Oct' value='494' color='008ED6' />
<set name='Nov' value='761' color='9D080D' />
<set name='Dec' value='960' color='A186BE' />
</graph>

Fusion charts have now appeared all over my applications and I still haven’t run out of options, but I know that if I do need more charting power I can easily upgrade to their premium charting controls which have all the charting functionality you could think of.

Fusion charts have great examples for chart integration with PHP, ASP, VB.NET (ASP.NET) and C# (ASP.NET) you can find out more at http://www.fusioncharts.com/Free/

December 5th, 2008 | Leave a Comment

ie6 png transparency

ie6 png transparency problem example image

ie6 png transparency problem example image

I recently encountered an issue regarding png transparency on older browsers whilst developing a website targeted at schools.

The web site used png transparency to display rounded corders and tabs over a sky background.  It worked well in all modern browsers but in ie6 and lower the png transparency was replaced by an ugly grey box.

Due to the project specifications identifying ie6 in the browser compatibility list it was necessary to find a solution to the problem.

I spent some time researching possible solutions and tried a few out, some worked, some were difficult to implement and others just didn’t seem to work at all.  After some time I settled upon a solution and have documented it with the following example:

ie6 png transparency problem

The solution involves 2 methods for dealing with png transparency, one to handle img tags in the html and one to handle css background images.  I have also documented how to overcome the issue with non clickable links after implementing the css only png transparency solution.

October 30th, 2008 | Leave a Comment

Powered by WordPress | Blue Weed by Blog Oh! Blog | Entries (RSS) and Comments (RSS).