Roadblocks utilizing ASP.NET 3.5 and ASP.NET AJAX - part 2

This is a continuation of the previous post. (http://anthony-yio.blogspot.com/2010/03/roadblocks-utilizing-aspnet-35-and.html)


ASP.NET Dropdownlist with tooltip

Problem: Although it might occur to everyone that dropdownlist when the text in it is too lengthy, there should have some tooltip to show the text in the dropdownlist like "any" combobox in Windows. But to your surprise, this feature does not come for free on ASP.NET 1.1, 2.0, 3.0, 3.5 or may be even 4.0.

Resolution:

(quote from - http://forums.asp.net/p/903935/994720.aspx)

I have search many solutions, some used JQuery, some use CSS and etc. But i do not like to mess around too much with the CSS and Javascript/JQuery for this sort of thing since i am doing MVP+Controller model. A little or non scripting is preferred.
Therefore, it is to add the title attribute to the item

Add a ondatabound="ApplyOptionTitles" event to your DropDownList control.

Then implement in code-behind (C#) as follows:

protected void ApplyOptionTitles(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
if (ddl != null)
{
foreach (ListItem item in ddl.Items)
{
item.Attributes["title"] = item.Text;
}
}
}

Data bound controls

Problem: There is no dedicated function to refresh the content of the AJAX controls that bound to data source suppose if you have updated the records in the database. The only way is to reload the page which defeat the purpose of having AJAX.

Resolution: The original thought is to call databind or rebind function but it does not work. (Wonder what the use of having those functions then? Basically, it would check if there is any changes to data source "name", or else calling those functions do nothing.. duh...)

So, the workaround are below
1. Datasource set to null programmically and then call databind() and then set the datasource back to the original one and call databind() - Which look like a mess.

2. If you have control parameters or session parameters. Just reset those value like set to null and back to original value. This would work even on AJAX. - The slightly better way...

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file