Tuesday, May 8, 2012

Free vector Vector banner Abstract Banners Set Vector Illustration

Flash header

http://www.flashvortex.com/generators.php?exampleId=284

Open source noncommerace shopping cart project

Project Description
nopCommerce is the best Open Source online shop e-commerce solution. nopCommerce is available for free. It has everything you need to get started in selling physical and digital goods over the internet.
for download plz visit:
 http://nopcommerce.codeplex.com/

CheckBoxList client side validation using JQuery

---------------- <b>JQuery Code for two CheckBoxLists</b> --------------------
    <script type="text/javascript">
        $(function() {
            function checkBoxClicked() {
                //Get the total of selected CheckBoxes
                var n1 = $("#list1 input:checked").length;
                var n2 = $("#list2 input:checked").length;
                //Set the value of the txtCheckbox control
                $("input:#txtCheckbox").val(n1 == 0 ? "" : n1);
                $("input:#txtCheckbox2").val(n2 == 0 ? "" : n2);
            }

            //intercept any check box click event inside the #list Div
            $("#list1 :checkbox").click(checkBoxClicked);
            $("#list2 :checkbox").click(checkBoxClicked);
        });
    </script>
---------------------------------------------------------------------


 -------------------------- <b>HTML Code for Two CheckBoxLists</b> -----------------
             <tr>
                <td colspan="2">
                    <div id="list1">
                        <asp:CheckBoxList ID="chklHobbies" runat="server" ValidationGroup="testGroup" RepeatDirection="Vertical"
                            RepeatLayout="Table" RepeatColumns="3">
                            <asp:ListItem Text="Sport" Value="Sport" />
                            <asp:ListItem Text="Fishing" Value="Fishing" />
                            <asp:ListItem Text="Reading Books" Value="ReadingBooks" />
                            <asp:ListItem Text="Swimming" Value="Swimming" />
                            <asp:ListItem Text="Listening To Music" Value="ListiningToMusic" />
                        </asp:CheckBoxList>
                        <div style='display:none;'>
                            <asp:TextBox ID="txtCheckbox" runat="server" ValidationGroup="testGroup" />
                            <asp:RequiredFieldValidator ID="valCheckboxList" Display="None" ErrorMessage="At least one hobby value must be selected 1"
                                runat="server" ControlToValidate="txtCheckbox" ValidationGroup="testGroup" EnableClientScript="true">*</asp:RequiredFieldValidator>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div id="list2">
                        <asp:CheckBoxList ID="chklHobbies2" runat="server" ValidationGroup="testGroup" RepeatDirection="Vertical"
                            RepeatLayout="Table" RepeatColumns="3">
                            <asp:ListItem Text="Sport" Value="Sport" />
                            <asp:ListItem Text="Fishing" Value="Fishing" />
                            <asp:ListItem Text="Reading Books" Value="ReadingBooks" />
                            <asp:ListItem Text="Swimming" Value="Swimming" />
                            <asp:ListItem Text="Listening To Music" Value="ListiningToMusic" />
                        </asp:CheckBoxList>
                        <div style='display:none;'>
                            <asp:TextBox ID="txtCheckbox2" runat="server" ValidationGroup="testGroup" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Display="None" ErrorMessage="At least one hobby value must be selected 2"
                                runat="server" ControlToValidate="txtCheckbox2" ValidationGroup="testGroup" EnableClientScript="true">*</asp:RequiredFieldValidator>
                        </div>
                    </div>
                </td>
            </tr>

----------------------------------------------------------------------

JavaScript for Clientside validation for asp.net Single-CheckBox using CustomValidator

<script  language="javascript" type ="text/javascript" >
function checkAgreement(source, args)
{
var elem = document.getElementById("cbxPDCheque");
if (elem.checked)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
</script>
 
<asp:CheckBox ID="cbxPDCheque" runat="server" AutoPostBack="True" Text="PD Cheques" />
<asp:CustomValidator ID="CustomValidator1" runat="server" EnableClientScript ="true"
ErrorMessage="Select PD Cheques." ClientValidationFunction ="checkAgreement" >*</asp:CustomValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" />
<asp:Button ID="Button1" runat="server" Text="Button" />
 
http://www.codeproject.com/Questions/188889/JavaScript-for-Clientside-validation-for-asp-net-S  

Thursday, May 3, 2012

Export DataTable to Excel File in asp.net

dt = city.GetAllCity();//your datatable 
string attachment = "attachment; filename=city.xls"; 
 Response.ClearContent(); Response.AddHeader("content-disposition", attachment);
  Response.ContentType = "application/vnd.ms-excel"; string tab = ""; 
 foreach (DataColumn dc in dt.Columns) { 
   
Response.Write(tab + dc.ColumnName);
    tab
= "\t"; } Response.Write("\n"); int i; foreach (DataRow dr in dt.Rows) {
    tab
= "";
   
for (i = 0; i < dt.Columns.Count; i++)
   
{
       
Response.Write(tab + dr[i].ToString());
        tab
= "\t";
   
}
   
Response.Write("\n"); } Response.End(); 
 
 
http://stackoverflow.com/questions/7843822/export-datatable-to-excel-file-in-asp-net 

Adding Facebook Share Functionality to an ASP.NET Website

Adding Facebook Share Functionality to an ASP.NET Website
<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">
    <title>Facebook share sampel</title>
    <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"
           type="text/javascript">
</script>
</head>

<body>

<form id="Form1" runat="server">

<div>

 <a name="sharebutton" type="button" href="http://www.facebook.com/sharer.php">Share</a>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

</div>

</form>

</body>

</html>





Aspx.cs



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Sharefacebook : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "<a name=\"fb_share\" type=\"button\"></a>" +
"<script " +
"src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " +
"type=\"text/javascript\"></script>";
HtmlMeta tag = new HtmlMeta();
tag.Name = "title";
tag.Content = "This is the page title";
Page.Header.Controls.Add(tag);
HtmlMeta tag1 = new HtmlMeta();
tag.Name = "description";
tag.Content = "This is a page description.";
Page.Header.Controls.Add(tag1);
}
} 

OR
 
 
using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Net.Mail;

namespace MHT_Web_Site
{
public partial class MyPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
labelSteps_1_2.Text = "<a name=\"fb_share\" type=\"button\"></a>" +
"<script " +
"src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " +
"type=\"text/javascript\"></script>";

HtmlMeta tag = new HtmlMeta();
tag.Name = "title";
tag.Content = “This is the Title”;
Page.Header.Controls.Add(tag);

HtmlMeta tag = new HtmlMeta();
tag.Name = "description";
tag.Content = “This is a short summary of the page.”;
Page.Header.Controls.Add(tag);

HtmlLink link = new HtmlLink();
link.Href = “http://www.murrayhilltech.com/images/LogoColorNoText.jpg”;
link.Attributes["rel"] = "image_src";
Page.Header.Controls.Add(link);

}
catch (Exception ex)
{
// Handle the exception
}
}
}
}

Wednesday, May 2, 2012

Encrypting Configuration Information in ASP.NET 2.0 Applications

When creating ASP.NET 2.0 applications, developers commonly store sensitive configuration information in the Web.configfile. The cannonical example is database connection strings, but other sensitive information included in the Web.configfile can include SMTP server connection information and user credentials, among others. While ASP.NET is configured, by default, to reject all HTTP requests to resources with the .config extension, the sensitive information in Web.configcan be compromised if a hacker obtains access to your web server's file system. For example, perhaps you forgot to disallow anonymous FTP access to your website, thereby allowing a hacker to simply FTP in and download your Web.config file. Eep.
Fortunately ASP.NET 2.0 helps mitigate this problem by allowing selective portions of the Web.config file to be encrypted, such as the <connectionStrings> section, or some custom config section used by your application. Configuration sections can be easily encrypted using code or aspnet_regiis.exe, a command-line program. Once encrypted, the Web.config settings are safe from prying eyes. Furthermore, when retrieving encrypted congifuration settings programmatically in your ASP.NET pages, ASP.NET will automatically decrypt the encrypted sections its reading. In short, once the configuration information in encrypted, you don't need to write any further code or take any further action to use that encrypted data in your application.
In this article we'll see how to programmatically encrypt and decrypt portions of the configuration settings and look at using the aspnet_regiis.exe command-line program. We'll then evaluate the encryption options ASP.NET 2.0 offers. There's also a short discussion on how to encrypt configuration information in ASP.NET version 1.x. Read on to learn more!
http://www.4guysfromrolla.com/articles/021506-1.aspx

Save username and password in cookies in asp.net

My web application's home page has a RememberMe checkbox.. If the user checks it, i ll store emailId and password in cookies.. My code is::::


if (this.ChkRememberme != null && this.ChkRememberme.Checked == true)
   
{
     
HttpCookie cookie = new HttpCookie(TxtUserName.Text, TxtPassword.Text);
     cookie
.Expires.AddYears(1);
     
Response.Cookies.Add(cookie);
   
}