How to Use Facebook to Authenticate Your ASP.NET MVC WEbsite

ASP.NET MVC has just integrated an open source library called DotNetOpenAuth (DNOA). This feature is originally created to add OAuth and OID Authentication capabilities. What the library does is that it bakes in the functionality so your application can be an OAuth Server or OAuth client or even both.

If you have a facebook account, you need to verify either through credit card or your telephone number. If you are using a phone, it must be capable of recieving text messages.

With this prerequisite ready, you should now be able to get started.

Read the rest of the tutorial here:  http://www.dotnetcurry.com/ShowArticle.aspx?ID=873

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Razor WebGrid to PDF Using iTextSharp

This article will help you provide your users with the ability to export contents of Razor WebPages Webgrid to a PDF file using iTextSharp. It is a simple, and easy-to-follow tutorial.

All you need to do is get a hold of iTextSharp Library. You can do this within WebMatrix using the built-in Nuget feature. Just click the nugget button on the main menu and type “iTextSharp” in the search box.

There are a couple of iTextSharp versions available, so I suggest you pick the most recent version which is released under GNU Affero Public License.

For the rest of the tutorial, visit this blog: http://www.mikesdotnetting.com/Article/205/Exporting-The-Razor-WebGrid-To-PDF-Using-iTextSharp

 

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Avoid DataBinder.Eval to Improve Perfomance in ASP.NET

A lot of developers use DataBinder.Eval to evaluate data expressions at run time. Although it is frequently used in web controls like GridView and Repeater, it can cause performance decrease compared to standard ASP.NET data-binding syntax.

This is because this method performs late-bound evaluation using reflection at run time. You are executing Eval() many times in which can cause performance issue because Data.Eval() uses reflection to evaluate data-binding expressions. So if you use this a lot, performance will significanlty decrease.

To avoid using DataBinder.Eval use the following alternatives:

  • For ObjectDataSource
  • For SqlDataSource

Read the rest of the tutorial here: http://www.devcurry.com/2011/02/how-to-avoid-databindereval-in-aspnet.html

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Lesser Known ASP.NET Repeater Control Tips

ASP.NET Repeater control is a lightweight data-bound list control which lets you customize your layout by repeating a specified template. This article will show the three lesser known ASP.NET Control tips.

Do you know that:

You can bind ASP.NET Repeater to List <string>
Just declare a List<string> then let it exposed to a get/set property . This will allow you to consume this List<> using LINQDataSource.

You can access checkbox inside a repeater programmatically
To do that, just use the code in the rptName_ItemDataBound() event. In this code below, we are assuming that the married property is bound to the checkbox:

foreach (RepeaterItem item in rptName.Items)
{
CheckBox cb = item.FindControl(“chkbox”) as CheckBox;
if (cb.Checked)
{
Response.Write(“Status: ” + cb.Attributes[“married”].ToString() + “< br />”);
}
}

Read the rest of the article here: http://www.devcurry.com/2013/02/3-aspnet-repeater-control-tips.html

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

ASP.NET 4 Granular View State

This article will explain how to control a view state at Page level as well as in control level. ASP.NET 4,0 has a property called “ViewStateMode” at control level. This property will let you turn FF the view state at Page level and turn ON view state at control level if it meets the requirements.

Do note that in ASP.NET 3.5, you can disable the view state at web application level from your web.config file. You cannot enable it at control or page level.

Read the rest of the tutorial and download the source code here:  http://www.devcurry.com/2011/05/aspnet-4-granular-view-state.html

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Tests Email in ASP.NET Without a Mail Server

If you’ve been testing emails online and is frustrated about it, there is a way in which you can test emails using ASP.NET even without a mail server. This procedure is a bit old but many developers don’t knowabout it. For example you are creating an application to test a module that sends bulk emails. Your first though would be to configure a SMTP server and test the email module. However, there is a trick in which you can test emails without a mail server.

First use this setting in your web config:
<system.net>
<mailSettings>
<smtp deliveryMethod=”SpecifiedPickupDirectory”>
<specifiedPickupDirectory pickupDirectoryLocation=”C:\Mails\”/>
</smtp>
</mailSettings>
</system.net>

The follow additional instructions in this blog:  http://www.devcurry.com/2011/03/test-emails-in-aspnet-without-mail.html

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Practical Recursion with Web Matrix

Recursive methods are those methods that call themselves to solve a number of practical probvlems. like for example managing and displaying heirarchical data. This article will explore scenarios on how to design a recursive helper nd functions that can be used in your website.

To give you an idea, methods can “call themselves” using this code:

@functions{
public static int Add(int number){
if(number > 0){
return number + Add(number -1);
}
return 0;
}
}

 

This method takes and int then repeatedly calls itself then reduce the number by 1 until it reaches zero. It then return the sum of all reductions.

Read the rest of the tutorial here: http://www.mikesdotnetting.com/Article/208/Practical-Recursion-in-ASP.NET-Web-Pages-with-WebMatrix

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Top 10 Tips for Writing High-Performance Web Applications

Writing a web application using ASP.NET is very easy. So easy that a lot of web developers take the time to structure applications for optimal performance. This article presents the top 10 tips in writing high performance web applications.

Many of these tips are very simple and easy to use that you wouldn’t know that it can actually improve its overall performance.

Expect to improve web application peformance through:

  1. returning multiple result sets
  2. paging data access
  3. connection pooling
  4. using cache API
  5. Per request caching
  6. background processing
  7. page output caching and proxy servers
  8. running IIS 6.0
  9. using GZip compression
  10. server control view state

Read the rest of the tutorial here: http://msdn.microsoft.com/en-us/magazine/cc163854.aspx

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Bitrix Site Manager ASP.NET Version 5.5 Offers Improved Social Media Capabilities

bitrixsitemanageraspBitrix, a PHP-based Web CMS site manager have fewer upgrades in its ASP.NET version which was introduced in the late 2009. But this week, Bitrix has release a new version (Bitrix V5.5) which comes with quick-start solutions as well as performance improvements.

Many of the new features are mirrored from the PHP version and like it, users can change the structure of the ASP.NET version while providing variations in design and colors which can be adjusted based on what they are used for.

Bitrix also introduces adaptive interface, a user-friendly interface which enable users to cut out some of the requirements for developers and be more focused on non-technical users.

Read the rest of the information in CMSwire.

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Display ASP.NET Validators Validation Error Messages Inside TextBox Control

Do you know that you can display the validation failed error messages of ASP.NET Valdatorcontrols inside ASP.NET Textbox control using JQuery? This tutorial is possible for ASP.NET Validator controls like RegularExpressionsValidator, CompareValidator, RangeValidator, RequiredFieldValidator, and CustomValidator.

Configure you code in just three steps:

1. Set the display property of all Validators to Dynamic
2. Set the CSSClass property of all validators to Validators
3. Inherit JQuery and Float JScript (JS) and write the JQuery script.

Then complete the HTML markup using this code:

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
    <title></title>
    <script src=”Scripts/jquery-1.4.1.min.js” type=”text/javascript”></script>
    <script src=”Scripts/Float.js” type=”text/javascript”></script>
    <script type = ”text/javascript”>
        $(function () {
            $(“.Validators”).Float();
       });
    </script>
</head>
<body style = ”font-family:Arial;font-size:10pt”>
    <form id=”form1″ runat=”server”>
    Name: (Required)<br />
    <asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>
    <asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ CssClass=”Validators”
    Display=”Dynamic” ControlToValidate=”txtName” runat=”server”
    ErrorMessage=”Name is required.”></asp:RequiredFieldValidator>
    <hr />
    Email: (Required and Valid Email Address)<br />
    <asp:TextBox ID=”txtEmail” runat=”server”></asp:TextBox>
    <asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ CssClass=”Validators”
    Display=”Dynamic” ControlToValidate=”txtEmail” runat=”server”
    ErrorMessage=”Email is required.”></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID=”RegularExpressionValidator6″ runat=”server”
        ErrorMessage=”Invalid Email Address”
        ControlToValidate=”txtEmail” CssClass=”Validators” Display=”dynamic”
        ValidationExpression=”\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”>
    </asp:RegularExpressionValidator>
    <hr />
    Age: (Required and Range 18 – 45)<br />
    <asp:TextBox ID=”txtAge” runat=”server”></asp:TextBox>
    <asp:RequiredFieldValidator ID=”RequiredFieldValidator3″ CssClass=”Validators”
        Display=”Dynamic” ControlToValidate=”txtAge” runat=”server”
        ErrorMessage=”Age is required.”></asp:RequiredFieldValidator>
    <asp:RangeValidator ID=”RangeValidator1″ CssClass=”Validators” Display=”Dynamic”
        MinimumValue=”18″ MaximumValue=”45″ Type=”Integer” ControlToValidate=”txtAge”
        runat=”server” ErrorMessage=”Age Range 18 to 45″></asp:RangeValidator>
    <br />
    <br />
    <asp:Button ID=”Button1″ runat=”server” Text=”Submit” />
    </form>
</body>
</html>

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS