Archive for January 2014
Working with Dynamic Pagination in ASP.NET
Pagination is a typical process in data display whereby large sets of data are broken into discrete sections for viewing, more often than not used in conjunction with some type of grid or list component.
CSHTML:
@using Smp.Web.Common;
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
.
Working with Cookies in ASP.NET
Usage of Cookies in ASP.NET using C# or jQuery. A cookie is a piece of data which is sent from a website and stored locally by the user’s browser. Cookies are needed because HTTP is stateless. This means that HTTP itself has no way to keep track of.
Working with Session in ASP.NET
Usage of Session in ASP.NET using C# or jQuery. A session is a piece of data which is sent from a website and stored locally by the user’s browser. Sessions are needed because HTTP is stateless. This means that HTTP itself has no way to keep track of.
How to upload file using jQuery/Ajax?
The following AJAX File Upload jQuery Tutorial covers how to upload files asynchronously using jQuery Framework.
Generic Handler: AjaxFileUploader.ashx
public class AjaxFileUploader : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
.
How to Remove the white spaces at the start and end of the string?
The $.trim() function removes all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of the supplied string. If these whitespace characters occur in the middle of the string, they are preserved.
<!doctype html>
<html.
How to Limit the number of characters allowed in form input text field?
By using the following attribute we can easily limit the number of characters allowed in form input text field.
maxlength="10"
Adding this attribute to your control:
<input type="text"
id="txtPhone"
name="Phone".
How to get the Created & last Published date of a Node in Umbraco?
Using the following CSHTML code we can easily get the Created & last Published date of a Node in Umbraco.
To get the Created Date of an Umbraco Node:
@Model.CreateDate
To get the Last Published Date of an Umbraco Node:
@Model.UpdateDa.
How to get the value of a CSS property using jQuery?
Consider the following HTML:
<div id="jjTechSol" style="height: 50px;width: 50px;">
<p>Content</p>
</div>
The following jQuery is used to get the value of a CSS property.
<script type="text/javascript">
$(document).ready(function.
How to Compare two fields with jQuery validate plugin?
Consider the following HTML.
<input type="text" id="txtEmail" name="Email" />
<input type="text" id="txtConfirmEmail" name="ConfirmEmail" />
The following script is used to Compare two fields with jQuery validate plugin.
$('#myform').validate({
.
How to convert the first character of a string into upper case?
The following C# code is used to convert the first character of a string into upper case.
static string UppercaseFirst(string s)
{
// Check for empty string.
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}
// Return char and.
How to convert all first letters of a sentence into upper case and rest of the letters into lower case?
The following C# code is used to convert all first letters of a sentence into upper case and rest of the letters into lower case.
string s = "THIS IS MY TEXT RIGHT NOW";
s = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(s.ToLower());
//.
How to check whether an Umbraco Node has children or not?
The following Razor code is used to check whether an Umbraco Node has children or not.
bool hasChildren = (Model.ChildrenAsList.Count() > 0);
if(hasChildren)
{
//code
}
else
{
//code
}.
Razor function to fetch the Data Type Items in Umbraco
The following Razor function is used to fetch the Data Type Items in Umbraco.
Namespaces Required:
using System.Xml.XPath;using umbraco.MacroEngines;
@functions{
public List<string> FetchDataTypeItems(int DataTypeNodeID)
.
How to get the URL of the current page
The following code is used to get the URL of the current page.
string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx
string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx
string.