Skip to content

Instantly share code, notes, and snippets.

@umair-me
umair-me / gist:6580786
Created September 16, 2013 13:37
jQuery checkbox click to show/hide div
$('#CheckBoxID').click(function () {
if ($(this).is(':checked')) {
$('#DivID').show();
} else {
$('#DivID').hide();
}
});
@umair-me
umair-me / Helpers.cs
Created September 16, 2013 14:17 — forked from jonezy/Helpers.cs
Set select item to dropdownlist
using System;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using MiniRideAndDrive.Web.Data;
public static partial class Helpers {
public static string BaseUrl {
@umair-me
umair-me / gist:6587647
Last active October 16, 2018 10:25
Bind javascript funtions after ajax postback
function BindEvents()
{
// Here your js function calls go
}
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(BindEvents);
--- OR---
@umair-me
umair-me / NVC2QueryString.cs
Last active December 23, 2015 06:19
Convert a NameValueCollection to a Querystring
/// <summary>
/// Constructs a NameValueCollection into a query string.
/// </summary>
/// <remarks>Consider this method to be the opposite of "System.Web.HttpUtility.ParseQueryString"</remarks>
/// <param name="parameters">The NameValueCollection</param>
/// <param name="delimiter">The String to delimit the key/value pairs</param>
/// <returns>A key/value structured query string, delimited by the specified String</returns>
public static string ToQueryString(this NameValueCollection parameters, String delimiter, Boolean omitEmpty)
{
if (String.IsNullOrEmpty(delimiter))
@umair-me
umair-me / RedirectSelf.cs
Created September 19, 2013 12:39
Redirect the current request back to the current page
/// <summary>
/// Redirect the current request back to the current page = full page reload
/// </summary>
public static void RedirectSelf(this HttpResponse response)
{
response.Redirect(HttpContext.Current.Request.RawUrl);
}
@umair-me
umair-me / gist:6663162
Created September 22, 2013 19:51
Delete a project from team foundation server
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE
Open a Command Prompt in the above folder and then run the delete command like below:
(don't forget the "/DefaultCollection" bit and remember to use quotation marks around your team project name if it has spaces in it)
tfsdeleteproject.exe /force /collection:https://<YourCollection>.VisualStudio.com/DefaultCollection "My project name with spaces"
@umair-me
umair-me / gist:6696694
Created September 25, 2013 08:29
List of MVC questions / other helpful links
http://www.codeproject.com/Articles/653746/Top-10-ASP-NET-MVC-Interview-Questions
http://www.codeproject.com/Articles/639717/MVC-Interview-Questions-and-Answers-All-about-MVC
@umair-me
umair-me / new_gist_file
Created September 25, 2013 13:47
Reset Identity Column value SQL Server
DBCC CHECKIDENT (tableName, RESEED, 10)
Note that the next value will be whatever you reseed with + 1, so in this case I set it to 10 so that the next value will be 11.
@umair-me
umair-me / gist:6699851
Created September 25, 2013 13:47
Random MVC Stuff
http://www.codeproject.com/Articles/657264/Couple-of-not-so-different-approaches-to-paging-in
http://www.codeproject.com/Articles/533932/Custom-ASP-NET-MVC-ActionResults
@umair-me
umair-me / new_gist_file
Created October 1, 2013 13:15
recaptcha not working in asp.net
protected void Button1_Click(object sender, EventArgs e)
{
Page.Validate(); <--- you need this
if (Page.IsValid)
{
lblResult.Text = "All Good";
}
else
{
lblResult.Text = "The words you entered are incorrect";