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

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();
}
 
ViewBag.MetaTag = HomeMetaTags();
@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});
    }

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

 
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

Cleaning up ASP.NET MVC Controllers

http://www.paulstovell.com/clean-aspnet-mvc-controllers

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

The Big Glossary of Open Source JavaScript and Web Frameworks with Cool Names

http://www.hanselman.com/blog/TheBigGlossaryOfOpenSourceJavaScriptAndWebFrameworksWithCoolNames.aspx

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

Request Validation with ASP.NET 4.5 : A deep dive

http://brijbhushan.net/2012/04/03/request-validation-with-asp-net-4-5-a-deep-dive/

ASP.NET page life cycle

ASP.NET + IIS + DNS Records = Sub Domain on the fly

http://www.dotnetexpertguide.com/2012/04/aspnet-iis-dns-records-sub-domain-on.html

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

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

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>

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/

Tuesday, April 3, 2012

THE FUTURE OF MOBILE

Connected Devices Growth

http://www.businessinsider.com/the-future-of-mobile-deck-2012-3?utm_source=twbutton&utm_medium=social&utm_campaign=sai

Validating Forms without using JavaScript

http://www.cssjockey.com/web-design-tutorials/introduction-to-html5-forms-and-css3-pseudo-classes


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 />

Templify for ASP.NET MVC Solutions

http://www.eggheadcafe.com/tutorials/asp-net/39125353-a2ad-4bb9-8d47-93e23aa92bb1/using-sarp-architecture-with-templify-for-aspnet-mvc-solutions.aspx



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/

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