Posts

Showing posts from April, 2013

How do I flip a bit in SQL Server, Boolean 'NOT' in T-SQL

Use the ~ operator: DECLARE @Bool bit SET @Bool = 0 SET @Bool = ~@Bool SELECT @Boole

change chartset from Code

You can use Like this Code private string ConvertUnicode(string Str) { Encoding latinEncoding = Encoding.GetEncoding("Windows-1252"); Encoding ArabicEncoding = Encoding.GetEncoding("Windows-1256"); byte[] latinBytes = latinEncoding.GetBytes(Str); return ArabicEncoding.GetString(latinBytes); }

jQuery lightbox

prettyPhoto is a jQuery lightbox clone. Not only does it support images, it also support for videos, flash, YouTube, iframes and ajax. It’s a full blown media lightbox. http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/#prettyPhoto

How to call object in Parent Iframe by jQuery

To find in the parent of the iFrame use: $('#parentPrice', window.parent.document).html(); The second parameter for the $() wrapper is the context in which to search. This defaults to document.

SessionID in ASP.NET MVC

session Id every 2-3 request will be changes shouldn't it remain the same because : ASP.NET keeps assigning new session ids until you place something into the Session variable Session.SessionID so you can't use it for make it use Session Start and save a variable on Session. Like this : void Session_Start(object sender, EventArgs e) { session["SessionID"] = Guid.NewGuid().ToString(); }

Mobile Device Detection ASP.NET

In ASP.NET, you can easily detect the mobile device request using Request.Browser.IsMobileDevice property and Request.UserAgent. The following code checks the IsMobileDevice property and redirects to the mobile specific page: protected void Page_Load(object sender, EventArgs e) { if (Request.Browser.IsMobileDevice) { Response.Redirec("~/default_mobile.aspx"); } } In MVC3 exposes an IsMobileDevice flag in the Request.Browser object. So in your razor code, you can query this variable and render accordingly. For example, @if (Request.Browser.IsMobileDevice) { HTML here for mobile device } else { HTML for desktop device }

add option to select combobox

To add option to select you can use : $('#selectname').append($(" ").attr("value", value).text(text)); If you need to append multi value you can user: $.each(data, function(i, option) { $('#selectname').append($(' ').attr("value", option.id).text(option.name)); }); If you need to add option to first "top" of list use $('#sel_bat1').children(":first").before($(" ").attr("value", value).text(text));

Show a message when DataList is Empty

you can add on footer or header template as show on code below : <footertemplate> <asp:label id="lblNoData" runat="server" text="No Rows Found!" visible="<%#bool.Parse((DataListName.Items.Count==0).ToString())%>"></asp:label> </footertemplate>