Saturday, May 9, 2009

jQuery quick notes

Here is some quick notes while handling jQuery.

   1: // Locates all elements with type=Text
   2: $("input[type=text]")
   3:  
   4: // Selects all <div> element with 'title' attributes
   5: // whose value begins with 'my'
   6: $("div[title^=my]")
   7:  
   8: // Locates all links that refers PDF
   9: $("a[href$=.pdf]")
  10:  
  11: // Locates anchor elements having the value
  12: // someurl.com anywhere in the 'href' attribute
  13: $("a[href*=someurl.com]")
  14:  
  15: // Locates all the achor tags
  16: // coming inside a li tag
  17: $("li:has(a)")
  18:  
  19: // Locates anchor(a) tags inside a paragraph(p) tag
  20: // where anchor-tag having a cssClass="someCssClass"
  21: $("p a.someCssClass")
  22:  
  23: // Matches all anchor(a) tags
  24: $("a")
  25:  
  26: // Matches element having an id=someId
  27: $("a#someId")
  28:  
  29: // Matches all elements having a CssClass=someCssClass
  30: $(".someCssClass")
  31:  
  32: // Locates anchor(a) tag with Id=someId and cssClass=someCssClass
  33: $("a.someId.someCssClass")

Reference: Manning’s jQuery in Action.


I must say, it’s a must read book.

Thanks.

Friday, May 8, 2009

No jQuery intellisense in Visual Studio Workaround

If you are using jQuery 1.3.2 in Visual Studio 2008 or Visual Web Developer 2008 (SP1), you may come across scenario where you wont get the jQuery intellisense support, even if you add jquery-1.3.2-vsdoc2.js file to the aspx page.

The workaround is simple. All you’ve to do, is to rename the jquery-1.3.2-vsdoc2.js to jquery-1.3.2-vsdoc.js.

It looks like:

   1: <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>
   2: <script src="Scripts/jquery-1.3.2-vsdoc.js" type="text/javascript"></script>

Note: For making VS/VWD to support jQuery intellisense, you’ve to apply a patch from the VS Development team & can be downloaded from here.

Thursday, April 30, 2009

Gravatar using ASP.NET

I’m always attracted with the fancy features in web. This time, I fall in love with Gravatar. Its a global recognition of “YOU”, with the help of an e-mail Id.

If you don't have a Gravatar account, create on here.

The SRC attribute a Gravatar Image has the below mentioned syntax:

http://www.gravatar.com/avatar/[MD5_Hash_Value]?s=[Image_Size]

For loading your Gravatar image, all you’ve to do is to mention the Hash Value of your email id and the size of your Gravatar image.

Before start, drag-drop an Image control, TextBox (for accepting email Id) and Button control.

[Source-View]

   1: <body>
   2:     <form id="form1" runat="server">
   3:     <div>
   4:         <asp:Image ID="Image1" src="" runat="server" /><br />
   5:         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   6:         <asp:Button ID="Button1" runat="server" Text="Button" />
   7:     </div>
   8:     </form>
   9: </body>



[Code-View]





   1: // Page Load
   2: protected void Page_Load(object sender, EventArgs e)
   3: {
   4:     // Add SRC attribute to Iage1 at runtime
   5:     Image1.Attributes.Add("src", GetGravatarImageURL(TextBox1.Text.Trim(), 80));
   6: }
   7:  
   8: // Return Gravatar Image URL
   9: public static string GetGravatarImageURL(string emailId, int imgSize)
  10: {
  11:  
  12:     string hash = string.Empty;
  13:     string imageURL = string.Empty;
  14:  
  15:     // Convert emailID to lower-case
  16:     emailId = emailId.ToLower();
  17:  
  18:     hash = FormsAuthentication.HashPasswordForStoringInConfigFile(emailId, "MD5").ToLower();
  19:  
  20:     // build Gravatar Image URL
  21:     imageURL = "http://www.gravatar.com/avatar/" + hash + ".jpg?s=" + imgSize;
  22:  
  23:     return imageURL;
  24: }



Now just run/build(F5) your page. The image will looks like below:



noGravatar_Sample



This is the default Gravatar image.



noGravatar 



Now just, enter your email Id used for creating the Gravatar account. & hit the button.



Hurray you’re done. Just integrate at the comments section of your blog.





 myGravatar





This is my gravatar image



That's it & Thanks.

Saturday, April 25, 2009

Change GridView row values using RowUpdating event


The contents of this post has been moved to here. Please visit the link to view the contents.

Sorry for the inconvenience.

Thanks!

Wednesday, April 22, 2009

FF3 Ad over IE

Does anyone noticed this?

http://www.mozilla.com/en-US/firefox/ie.html

ff3_vs_ie8

See, the courage, confidence and power of Mozilla corporation; directly advertising over IE. Nothing to say more, IE market-share dipped to 66%. But, this time IE is losing the market-share in a quicker pace. IE8 have to struggle a lot to gain the market again and again.

Good luck, IE.

BTW, I’m an addicted IE user.

 
Best viewed in Internet Explorer 8.