$('#partialcontroldiv').load('@Url.Content("~/ControlerName/ActionName")?id=' + id, '', function () {
//below lines to reapply dataannotation validation on partial view
$('form').removeData("validator");
$("form").removeData("unobtrusiveValidation");
$.validator.unobtrusive.parse(document);
});...
Saturday, September 15, 2012
MVC 3: Generate Textbox or labels in Foreach Loop
@foreach (var item in Model )
{
@Html.LabelFor(a=> item.ItemName)
@Html.LabelFor(a => item.Description)
@Html.LabelFor(a => item.Qty)
@Html.TextBoxFor(a => item.Price)
...
Labels:
.NET Framework 4.0,
MVC3,
Razor
MVC 3: Cross Site Request Forgery protection
write @Html.AntiForgeryToken() in view to generate any forgery token (hidden textbox)
and use [ValidateAntiForgeryToken] on action to validate that request has valid anti forgery tok...
Labels:
.NET Framework 4.0,
AntiForgery,
MVC3,
Security
Change value of RequiresQuestionAndAnswer in ASP.NET Membership provider
MembershipUser user = Membership.GetUser();
string newPassword = "newPass";
string tempPassword = string.Empty;
if (Membership.Provider.RequiresQuestionAndAnswer)
{
var _requiresQA = Membership.Provider.GetType().GetField("_RequiresQuestionAndAnswer",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
//change the value in the private field
_requiresQA.SetValue(Membership.Provider, false);
//do...
Labels:
ASP.NET,
Authorization,
Membership,
MVC3
Singleton Session
public class SingletonSession
{
// private constructor
private SingletonSession()
{
}
// Gets the current session.
public static SingletonSession Current
{
get
{
SingletonSession session =
(SingletonSession)HttpContext.Current.Session["__SingletonSession__"];
if (session == null)
{
session = new SingletonSession();
HttpContext.Current.Session["__SingletonSession__"] = session;
}
return session;
}
}
// **** add your session...
Labels:
C#.NET,
Design Patterns,
Singleton
Authorization and Permission using Attribute in MVC3
Public enum PermissionType
{
permission1,
permission2,
permissiontype3
}
public class AuthorizePermissionAttribute : AuthorizeAttribute
{
private readonly IRolesService _rolesService;
private readonly IUserService _userService;
private string[] _rolesSplit;
private string[] _usersSplit;
public PermissionType[] PermissionName;
public AuthorizePermissionAttribute()
: this(new AspNetMembershipProviderWrapper(), new AspNetRoleProviderWrapper())
{
}
public...
Features of SQL Server 2012

Features
}Column
Store Index
}Sequence
objects
}Contained
Database
}Always
On (HADRON)
}Ad
Hoc Query Paging
}FileTable
}Audit
Enhancements
}Enhanced
PowerShell Support
}Big
Data Support
Column
Store Index
}Columnstore
indexes provide an easy way to significantly
improve data warehouse and decision support query performance...
Labels:
SQL Server 2012,
sqlserver
Tuesday, April 3, 2012
Using JQGrid in ASP.NET MVC 3
.Content(%22~/Images/edit.png%22)%20+%20%22)
JQGrid is one of the most powerful opensource grid available for commercial use.
We can easily use JQGrid in MVC 3 also, but instead of directly using JQGrid, i would like to refer to use any component/wrapper built over JQGrid, which can make data and grid structure in strongly typed form.
After lots of search i found a very good helper...
Monday, January 30, 2012
Best Extension Methods
Below is list of Best Extension Methods of .NET
Paging on IQueryable
Paging on IEnumerable
IEnumerable To DataTable
Convert Generic List to DataTable
Check Is Nullable
Get Core Type
Match a string with multiple strings
Add Range to Collection
Force Download a File
Generate HTML Table from IEnumerable
Log / Email the Exception
Resize the Image
Throw an exception if argument / parameter of function is null
Send...
Labels:
C#.NET,
Extension Methods
Best Extension Methods: Cookie Extension Methods
Best Cookies Extension Methods
public static class CookieExtensions
{
///
/// Sets a persistent cookie which expires after the given number of days
///
/// The HtmDocument to extend
/// the cookie key
/// the cookie value
/// The number of days before the cookie expires
public static void SetCookie(this HtmlDocument doc, string key, string value, int days)
{
DateTime expiration...
Labels:
C#.NET,
Extension Methods
Best Extension Methods: HTTP Extension Methods
Best Http Extension Methods
public static class HttpExtension
{
public static string HtmlEncode(this string data)
{
return HttpUtility.HtmlEncode(data);
}
public static string HtmlDecode(this string data)
{
return HttpUtility.HtmlDecode(data);
}
public static NameValueCollection ParseQueryString(this string query)
{
return HttpUtility.ParseQueryString(query);
}
...
Labels:
C#.NET,
Extension Methods
Best Extension Methods: String Extension Methods
Best String Extension Methods
public static class StringExtensions
{
///
/// if the string is NULL, converts it to string.empty. Helpful when trying to avoid null conditions.
///
///
///
public static string IsNullThenEmpty(this string inString)
{
if (inString == null)
return string.Empty;
else
return inString;
}
public static string[] GetStringInBetween(this...
Labels:
C#.NET,
Extension Methods
Best Extension Methods: Date and Time
Best Extension Methods for Date and time
public static class DateExtensions
{
///
/// DateDiff in SQL style.
/// Datepart implemented:
/// "year" (abbr. "yy", "yyyy"),
/// "quarter" (abbr. "qq", "q"),
/// "month" (abbr. "mm", "m"),
/// "day" (abbr. "dd", "d"),
/// "week" (abbr. "wk", "ww"),
/// "hour" (abbr. "hh"),
/// "minute" (abbr. "mi", "n"),...
Labels:
C#.NET,
Extension Methods
Subscribe to:
Posts (Atom)