Friday, January 28, 2011

How to detect if an element is hidden in jQuery

This will work when myID was hidden using .hide( ) and displayed using .show( )


if($("#myID").is(":visible"))
   $("#myID").hide();
else
   $("#myID").show();

How to get rid of Unexpected error 0x8ffe2740 occurred in IIS 5

Running XP, I stopped my Default website and rebooted my computer.

Then when I tried to restart my website, I was getting the error "Unexpected error 0x8ffe2740 occurred".

This was because Skype started before IIS.

To resolve, quite Skype, restart IIS, start your site, then restart Skype

Thursday, January 27, 2011

How to refresh Intellisense in SQL Server 2008

Intellisense in SQL Server 2008 Management Studio is a great feature. When adding a table, column etc, your Intellisense doesn't know about the change right away.

To fix this

Edit > Intellisense > Refresh Local Cache

Thursday, January 20, 2011

How to find the value of a dropdown in a user control using jQuery

you may have an asp:Dropdown control with an id="ddViewBy" like below.

<asp:DropDownList class="ddList" runat="server" ID="ddViewBy" AutoPostBack="true" OnSelectedIndexChanged="ddViewBy_Changed"><asp:DropDownList>

If your dropdownlist is in a user control and the usercontrol is in a content place holder, then when you view source, on the web page the id of the control would change to something like this:

id="ctl00_phContent_ucSearchFilter_ddViewBy"

To find the value of the dropdown using jQuery, use the following selector

$('select[id$=ddViewBy]').val();

This is reliable, because your user control could be in different place holders which would cause the first part of the id to be different. The controls id will always end with your original name.

The $= means "ends with"

Just an FYI, ^= means "begins with"


Wednesday, January 19, 2011

How to create the ASP.Net membership tables

Sometimes web hosts (such as godaddy) will set up the aspnet membership tables for you in your database as part of the setup.

When you need to set them up locally, use the following .Net framework command
//For servername you can use "(local)" if the database is a local SQL Server install
System.Web.Management.SqlServices.Install(txtServer.Text, txtUserName.Text, txtPassword.Text, txtDatabase.Text, SqlFeatures.All);