Monday, April 30, 2012
Friday, April 27, 2012
Dynamically creating meta tags in asp.net mvc by Html.Raw
http://www.dotnetjalps.com/2012/04/dynamically-creating-meta-tags-in.html
ViewBag.MetaTag = HomeMetaTags();
@Html.Raw(ViewBag.MetaTag)
public
string
HomeMetaTags()
{
System.Text.StringBuilder strMetaTag =
new
System.Text.StringBuilder();
strMetaTag.AppendFormat(
@"<meta content='{0}' name='Keywords'/>"
,
"Home Action Keyword"
);
strMetaTag.AppendFormat(
@"<meta content='{0}' name='Descption'/>"
,
"Home Description Keyword"
);
return
strMetaTag.ToString();
}
@Html.Raw(ViewBag.MetaTag)
Thursday, April 26, 2012
ASP.NET MVC & jQuery UI autocomplete
http://blogs.msdn.com/b/ukadc/archive/2012/04/24/asp-net-mvc-amp-jquery-ui-autocomplete.aspx
public static MvcHtmlString AutocompleteFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string actionName, string controllerName)
{
string autocompleteUrl = UrlHelper.GenerateUrl(null, actionName, controllerName,
null,
html.RouteCollection,
html.ViewContext.RequestContext,
includeImplicitMvcValues: true);
return html.TextBoxFor(expression, new { data_autocomplete_url = autocompleteUrl});
}
public static MvcHtmlString AutocompleteFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, string actionName, string controllerName)
{
string autocompleteUrl = UrlHelper.GenerateUrl(null, actionName, controllerName,
null,
html.RouteCollection,
html.ViewContext.RequestContext,
includeImplicitMvcValues: true);
return html.TextBoxFor(expression, new { data_autocomplete_url = autocompleteUrl});
}
Wednesday, April 25, 2012
Tuesday, April 24, 2012
ASP.NET MVC Authentication - Global Authentication and Allow Anonymous
http://weblogs.asp.net/jgalloway/archive/2012/04/18/asp-net-mvc-authentication-global-authentication-and-allow-anonymous.aspx#.T5VzxmwymMU.delicious
public
Reminder: Don't use web.config to restrict access, use [Authorize]
[AllowAnonymous]
public
ActionResult Login()
public
class
HomeController : AuthorizedController
How to set default value for Auto-Implemented Properties in C#
No direct way to do this.
Either set default value in Class constructor or design your property without auto-implemented
Either set default value in Class constructor or design your property without auto-implemented
Monday, April 23, 2012
Breadcrumbs in WebMatrix Web Pages
Breadcrumbs are often an important aid in user interface, allowing users to know their position in the site they are navigating.
http://www.codeproject.com/Articles/362320/Breadcrumbs-in-WebMatrix-Web-Pages
http://www.codeproject.com/Articles/362320/Breadcrumbs-in-WebMatrix-Web-Pages
Friday, April 20, 2012
Thursday, April 19, 2012
Tuesday, April 17, 2012
ASP.NET Forms Authentication Blocks Images and CSS Files
http://www.codingbeaver.com/myblog/index.php/2012/04/11/asp-net-forms-authentication-blocks-images-and-css-files/
<modules runAllManagedModulesForAllRequests="true" />
Monday, April 16, 2012
Friday, April 13, 2012
Paging in Classic ASP
ConnectionString ="DSN=DataSourceName"
SQLS = "SELECT * FROM TableName"
Set PRS = Server.CreateObject("ADODB.Recordset")
PRS.CursorLocation = 3 ' adUseClient
PRS.PageSize = 10
PRS.Open SQLS, ConnectionString
CurrentPage = 1
PRS.AbsolutePage = CurrentPage
Do While Not ( PRS.Eof Or PRS.AbsolutePage <> CurrentPage )
PRS.MoveNext
Loop
PRS.Close
set PRS = nothing
References:
http://support.microsoft.com/kb/202125
http://www.codeproject.com/Articles/619/ADO-Recordset-Paging-in-ASP
SQLS = "SELECT * FROM TableName"
Set PRS = Server.CreateObject("ADODB.Recordset")
PRS.CursorLocation = 3 ' adUseClient
PRS.PageSize = 10
PRS.Open SQLS, ConnectionString
CurrentPage = 1
PRS.AbsolutePage = CurrentPage
Do While Not ( PRS.Eof Or PRS.AbsolutePage <> CurrentPage )
PRS.MoveNext
Loop
PRS.Close
set PRS = nothing
References:
http://support.microsoft.com/kb/202125
http://www.codeproject.com/Articles/619/ADO-Recordset-Paging-in-ASP
Thursday, April 12, 2012
Tuesday, April 10, 2012
How to include TinyMCE editor in ASP.NET MVC 3 razor view?
- Download the latest version from: http://www.tinymce.com/download/download.php
- Extract JavaScript folder into a folder under Scripts, and include files into MVC project
- Copy and Paste following code into the view you want to use
<script type="text/javascript" src='@Url.Content("~/Scripts/tiny_mce/tiny_mce.js")'></script>
<script type="text/javascript">
tinyMCE.init({
mode: "textareas"
});
</script>
<form method="post" action="somepage">
<textarea name="content" style="width: 100%"></textarea>
</form>
- Most important thing: double check the path (JavaScript file tiny_mce.js) is correct
References for HTML editor:
HTML eidtor:
http://ckeditor.com/demo
http://www.tinymce.com/tryit/full.php
http://drupal.fckeditor.net/demo
http://www.webdesignerdepot.com/2008/12/20-excellent-free-rich-text-editors/
http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Using-CKEditor-and-TinyMCE-with-ASPNET-MVC.aspx
- Extract JavaScript folder into a folder under Scripts, and include files into MVC project
- Copy and Paste following code into the view you want to use
<script type="text/javascript" src='@Url.Content("~/Scripts/tiny_mce/tiny_mce.js")'></script>
<script type="text/javascript">
tinyMCE.init({
mode: "textareas"
});
</script>
<form method="post" action="somepage">
<textarea name="content" style="width: 100%"></textarea>
</form>
- Most important thing: double check the path (JavaScript file tiny_mce.js) is correct
References for HTML editor:
HTML eidtor:
http://ckeditor.com/demo
http://www.tinymce.com/tryit/full.php
http://drupal.fckeditor.net/demo
http://www.webdesignerdepot.com/2008/12/20-excellent-free-rich-text-editors/
http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Using-CKEditor-and-TinyMCE-with-ASPNET-MVC.aspx
Burnout is caused by resentment
must-haves to prevent me burning out are:
- Exercising 2 - 3 times a week
- Eating well (fruits and veggies)
- 8 hours of sleep at least 4 nights a week
- Unplugging totally for at least a week a year
Monday, April 9, 2012
Thursday, April 5, 2012
How to sovle "execution of the asp page caused the response buffer to exceed its configured limit." in Classic ASP
Solution#1:
Put this line on the top of page
<%Response.Buffer = False%>
Solution#2:
Limit your record number from database
Put this line on the top of page
<%Response.Buffer = False%>
Solution#2:
Limit your record number from database
Wednesday, April 4, 2012
How to put multiple div next to each other by CSS?
.oneDiv
{
width: 200px;
height: 200px;
display:inline-table;
}
<div>
<div class="oneDiv">1</div>
<div class="oneDiv">2</div>
<div class="oneDiv">3</div>
</div>
{
width: 200px;
height: 200px;
display:inline-table;
}
<div>
<div class="oneDiv">1</div>
<div class="oneDiv">2</div>
<div class="oneDiv">3</div>
</div>
Making your ASP.NET Web API’s secure
a ASP.NET Web API that requires requests to be under the HTTPS protocol, requires an encrypted authorization token and requires traffic to only come from a predefined population of IP addresses.
http://codebetter.com/johnvpetersen/2012/04/02/making-your-asp-net-web-apis-secure/
http://codebetter.com/johnvpetersen/2012/04/02/making-your-asp-net-web-apis-secure/
Tuesday, April 3, 2012
Validating Forms without using JavaScript
http://www.cssjockey.com/web-design-tutorials/introduction-to-html5-forms-and-css3-pseudo-classes
CSS
HTML 5
CSS
input:required{ border-color:red; } input:optional{ border-color:whitesmoke; }
HTML 5
<input type="text" name="name" id="first-name" placeholder="enter you first name" required />
SpecsFor.Mvc, an independent library for automated acceptance tests
http://trycatchfail.com/blog/post/Using-SpecsForMvc-Introduction.aspx
public class when_a_new_user_registers_with_invalid_data : SpecsFor<MvcWebApp> { protected override void Given() { SUT.NavigateTo<AccountController>(c => c.Register()); } protected override void When() { SUT.FindFormFor<RegisterModel>() .Field(m => m.Email).SetValueTo("notanemail") //.Field(m => m.UserName).SetValueTo("Test User") --Omit a required field. .Field(m => m.Password).SetValueTo("P@ssword!") .Field(m => m.ConfirmPassword).SetValueTo("SomethingElse") .Submit(); } //...snip... }
Monday, April 2, 2012
Combining LESS with ASP.NET
@back-color: #000;
@font-color: #fff;
body {
background-color: @back-color;
font-size: .85em;
font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif;
margin: 0;
padding: 0;
color: @font-color;
}
http://www.sitepoint.com/combining-less-with-asp-net/
@font-color: #fff;
body {
background-color: @back-color;
font-size: .85em;
font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif;
margin: 0;
padding: 0;
color: @font-color;
}
http://www.sitepoint.com/combining-less-with-asp-net/
ASP.net MVC generic client and server side validation
In ASP.net Webform has CustomValidator which can call any javascript function for validation and which make our task is easy in terms of validation.
Follwoing link show how to do it in MVC
http://www.dotnetstep.in/asp-net-mvc-generic-client-and-server-side-validation
Follwoing link show how to do it in MVC
http://www.dotnetstep.in/asp-net-mvc-generic-client-and-server-side-validation
Subscribe to:
Posts (Atom)