Latest Posts

Monday, December 31, 2012

regular expression rewrite path

  Match match = Regex.Match(origPath, @"([^/]*)/member/([^/]*)/([0-9]+)\.aspx$", RegexOptions.IgnoreCase);
        if (match.Success)
        {
            string pageID = match.Groups[3].Value;
            //Context.Response.Redirect("ViewMember.aspx?id=" + pageID);
            Context.RewritePath("../../ViewMember.aspx?id=" + pageID);
        }

regular expression trim

MemberName = System.Text.RegularExpressions.Regex.Replace(MemberName, "([^A-Za-z0-9()]$)", "");

PostBackUrl or CommandArgument

 PostBackUrl='<%# string.Format("~/ViewMember.aspx?id={0}",Eval("MemID")) %>'  

OR
                                         CommandArgument='<%# Eval("MemID")+":"+ Eval("MemberName") %>' 

Sunday, December 30, 2012

JSON Serialize

System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
        string sJSON = javaScriptSerializer.Serialize(memberProfileslist);
        context.Response.Write(sJSON);

Thursday, December 13, 2012

Jquery FadeIn FadeOut from DataBase

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Loop through an array using jQuery</title>
    <script src="http://code.jquery.com/jquery-latest.js"    
    type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function(){
              var arrNames = ['Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby'];
 
        $.each(arrNames, function(i, val) {
            setTimeout(function() {
                $('#divDisp').fadeOut("slow", function() {
                    $(this).text(val).fadeIn("slow");
                });
            },i * 3000);
        });
 });
    </script>
</head>
<body>
<div id="divDisp" style="background-color:#00ff00;"></div>
</body>
</html>

Jquery Animate from DataBase

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Loop through an array using jQuery</title>
    <script src="http://code.jquery.com/jquery-latest.js"    
    type="text/javascript"></script>
     <script type="text/javascript">
         $(document).ready(function(){
              var arrNames = ['Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby','Tom', 'Jane', 'Harry', 'Rick', 'Moby'];
 
        $.each(arrNames, function(i, val) {
            setTimeout(function() {
                $('#divDisp').animate({width:'0px'}, function() {
                    $(this).text(val).animate({width:'350px'});
                });
            },i * 3000);
        });
 });
    </script>
</head>
<body>
<div id="divDisp" style="background-color:#00ff00;"></div>
</body>
</html>

Tuesday, December 11, 2012

Display Inline Block

<html>
<head>
  <style type="text/css">
        .toolbar ul {
            display:block;
            width: 600px;
            padding: 0;
        }
        .toolbar ul li
        {
            display: inline-block;
            list-style-type: none;
            vertical-align: middle;
            border: solid 3px gray;
            margin: 2px;
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <ul>
            <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
            <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
 <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
            <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
        </ul>
    </div>
</body>
</html>

Display Table Property two

<html>
<head>
  <style type="text/css">
        .toolbar ul {
            display:table-row;
        }
        .toolbar ul li
        {
            display: table-cell;
            height: 100px;
            list-style-type: none;
            vertical-align: middle;
            border: solid 5px gray;
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <ul>
            <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
            <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
</ul><ul>
 <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
            <li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
<li><a href="#">first item<br />
                <img src='http://www.cfht.hawaii.edu/en/news/ngcfhtannounce/Banner_image2.jpg' width='100px' alt='' /><br />
                first item</a></li>
        </ul>
    </div>
</body>
</html>

Display Table Property

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        .toolbar ul {
            display:table-row;
        }
        .toolbar ul li
        {
            display: table-cell;
            height: 100px;
            list-style-type: none;
            margin: 10px;
            vertical-align: middle;
        }
        .toolbar ul li a {
            display:table-cell;
            vertical-align: middle;
            height:100px;
            border: solid 1px black;
        }
        .toolbar ul li.button a {
            height:50px;
            border: solid 1px black;
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <ul>
            <li><a href="#">first item<br />
                first item<br />
                first item</a></li>
            <li><a href="#">second item</a></li>
            <li><a href="#">last item</a></li>
            <li class="button"><a href="#">button<br />
                button</a></li>
        </ul>
    </div>
</body>
</html>

Monday, December 10, 2012

Jquery For Each Set Time Out and Ajax Tabes

<script type="text/javascript">
     $(document).ready(function () {
         $("#TabbedPanels1").tabs();
         $.ajax({
             type: "POST",
             url: "Default.aspx/lawersDetailsList",
             data: "{}",
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             success: function (data) {
                 var arrayList = data.d;
                 $.each(arrayList, function (i, val) {
                     setTimeout(function () {
                         $('#slide-1').fadeOut("slow", function () {
                             $(this).html("<h1>" + val.memberName + "</h1>" + "<p>" + val.offAddress + "</p>" + "<a href='LawyerProfile.aspx?id=" + val.memID + "'><img src='MemPhoto/" + val.imageID + "' /></a><br />").fadeIn("slow");
                         });
                     }, i * 5000);
                 });
             }
         });
         var arrayCount = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'];
         $.each(arrayCount, function (j, values) {
             setTimeout(function () {
                 $.ajax({
                     type: "POST",
                     url: "Default.aspx/memberProfilesList",
                     data: "{}",
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     success: function (data) {
                         var arrayList = data.d;
                         $("#membersProfile").fadeOut("slow");
                         $('#membersProfile').html("");
                         $.each(arrayList, function (i, val) {
                             $('#membersProfile').append("<a href='LawyerProfile.aspx?id=" + val.memID + "'><img src='MemPhoto/" + val.imageID + "' width='50px' /></a>");
                         });
                         $("#membersProfile").fadeIn("10000");
                     }
                 });
             }, j * 30000);
         });

         $('#TabbedPanels1').bind('tabsselect', function (event, ui) {
             var callMethod;
             var tabSelected = "#TabbedPanels1" + ui.index + "Selected";
             if ($(tabSelected).text() == "") {
                 switch (ui.index) {
                     case 1:
                         callMethod = "Default.aspx/NewsUpdatesCollections";
                         break;
                     case 2:
                         callMethod = "Default.aspx/DesignatedSeniorsList";
                         break;
                     case 3:
                         callMethod = "Default.aspx/MostViewedprofilesList";
                         break;
                     case 4:
                         callMethod = "Default.aspx/LastViewedprofilesList";
                         break;
                     case 5:
                         callMethod = "Default.aspx/RecentlyUpdatedMembersList";
                         break;

                 }

                 $.ajax({
                     type: "POST",
                     url: callMethod,
                     data: "{}",
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     async: true,
                     success: function (data) {
                         alert(data.d);

                         switch (ui.index) {
                             case 1:
                                 alert(data.d);
                                 break;
                             case 2, 3, 4, 5:
                                 alert(data.d);
                                 break;

                         }


                     }
                 });
             }
         });



     });
 </script>

Tuesday, November 6, 2012

Form Authentication

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="userDbConnectionString" connectionString="Data Source=localhost;Initial Catalog=sdsdfsdf;Integrated Security=True;" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>
    <authentication mode="Forms">
      <forms loginUrl="Login.aspx" name=".ASPXFORMSAUTH" protection="All">
      </forms>
    </authentication>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
  <location path="admin">
    <system.web>
      <authorization>
        <allow roles="admin"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="reseller">
    <system.web>
      <authorization>
        <allow roles="reseller"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="customer">
    <system.web>
      <authorization>
        <allow roles="customer"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
 </configuration>




protected void Button1_Click(object sender, EventArgs e)
    {
        user _user = new user();
        adminManager _adminManager = new adminManager();
        DataTable dt = new DataTable();
        dt = _adminManager.fetchuserDetails(TextBox1.Text);
        if (dt.Rows.Count > 0)
        {
            if (dt.Rows[0]["password"].ToString() == TextBox2.Text)
            {
                FormsAuthenticationTicket Authticket = new FormsAuthenticationTicket(
                                                        1,
                                                        dt.Rows[0]["emailID"].ToString(),
                                                        DateTime.Now,
                                                        DateTime.Now.AddMinutes(30),
                                                        CheckBox1.Checked,
                                                        dt.Rows[0]["role"].ToString(),
                                                        FormsAuthentication.FormsCookiePath);

                string hash = FormsAuthentication.Encrypt(Authticket);

                HttpCookie Authcookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);

                if (Authticket.IsPersistent) Authcookie.Expires = Authticket.Expiration;

                Response.Cookies.Add(Authcookie);

                string returnUrl = Request.QueryString["ReturnUrl"];
                if (returnUrl == null) returnUrl = "/";

                Response.Redirect(returnUrl);
            }
            else
            {
                Label1.Text = "Password does'nt match.";
            }
        }
        else
        {
            Label1.Text = "User not exists.";
        }
    }



protected void Page_Load(object sender, EventArgs e)
    {
        if (User.Identity.IsAuthenticated && Request.QueryString["ReturnUrl"] != null)
        {
            
        }

        Label1.Text = "";
    }

Sunday, November 4, 2012

jquery dialog box with jquery ui button

 <script type="text/javascript" src="js/jquery.1.7.min.js"></script>
    <script type="text/javascript" src="js/jquery.1.7.2.ui.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/blitzer/jquery-ui.css" type="text/css" rel="Stylesheet" />
    <link href="css/indiashoponline.css" rel="stylesheet" type="text/css" />
    <script src="js/SpryEffects.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $('#purchasetable').dialog({ autoOpen: false, modal: true, title: "Enter Purchase Details", width: 500, resizable: false,
                buttons: {
                    'Continue Purchase': function () {
                        var invalidcount = 0;
                        $("#purchasetable :input[type=text]").each(function (index, element) {
                            if (customvalidation(element) == false)
                                invalidcount = invalidcount + 1;
                        });
                        if (invalidcount == 0) {
                            $('#userdetails').dialog('open');
                            $('.ui-widget-overlay').click(function () {
                                $('#userdetails').dialog('close');
                            });
                        }
                    }
                }
            });
            $('#userdetails').dialog({ autoOpen: false, modal: true, title: "Enter User Details", width: 500, resizable: false,
                buttons: {
                    'Complete Purchase': function () {
                        var invalidcount2 = 0;
                        $("#userdetails :input[type=text]").each(function (index, element) {
                            if (customvalidation(element) == false)
                                invalidcount2 = invalidcount2 + 1;
                        });
                        if (invalidcount2 == 0) {
                            $('.ui-dialog-buttonpane button:contains(Complete Purchase)').attr("id", "completepurchasebtn");
                            $('#completepurchasebtn').attr("disabled", true);
                        }
                        if (invalidcount2 == 0) {
                            $.ajax({
                                type: "post",
                                url: "Default5.aspx/saveUserDetails",
                                data: "{productId:'productxt',userName:'" + $("#nametxt").val() + "',bomEmailId:'" + $("#bomEmailtxt").val() + "',amazonEmailId:'" + $("#amazonEmailtxt").val() + "',phoneNumber:'" + $("#phoneNumbertxt").val() + "',firstName:'" + $("#firstNametxt").val() + "',middleName:'" + $("#middleNametxt").val() + "',lastName:'" + $("#lastNametxt").val() + "',homeName:'" + $("#houseNametxt").val() + "',street:'" + $("#streettxt").val() + "',city:'" + $("#citytxt").val() + "',state:'" + $("#statetxt").val() + "',country:'" + $("#countrytxt").val() + "',zipCode:'" + $("#ziptxt").val() + "',mobile:'" + $("#mobiletxt").val() + "',homePhone:'" + $("#homePhonetxt").val() + "'}",
                                async: true,
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) {
                                    if (data.d == "2") {
                                        alert('Purchase Successful, Check your email for more details');
                                        $('#purchasetable').dialog('close');
                                        $('#userdetails').dialog('close');
                                    }
                                    else if (data.d == "3") {
                                        alert('Purchase Completed, Error on Email Sending');
                                        $('#purchasetable').dialog('close');
                                        $('#userdetails').dialog('close');
                                    }
                                },
                                error: function () {
                                    alert('Problem');
                                }
                            });
                        }
                    }
                }
            });

            $("#purchasetable :input").blur(function () {
                var element = $(this);
                customvalidation(element);
            });
            $("#userdetails :input").blur(function () {
                var element = $(this);
                customvalidation(element);
            });
        });
        function purchasepopup() {
            $('#purchasetable').dialog('open');
            $('.ui-widget-overlay').click(function () { $('#purchasetable').dialog('close'); });
        }
function customvalidation(element) {
    isvalid = true;
    var classname = $(element).attr('class');
    var value = $(element).val();
    if (classname.indexOf("optional") == -1 && value == "") {
        $(element).next("span").text('Field Required');
        isvalid = false;
    }
    else {
        $(element).next("span").text('');
        if (classname.indexOf("requireddb") != -1) {
            $.ajax({
                type: "post",
                url: "Default5.aspx/checkAmazonId",
                data: "{amazonId:'" + value + "'}",
                async: false,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "1") {
                        $(element).next("span").text('');
                    }
                    else if (data.d == "0") {
                        $(element).next("span").text('Purchased Already');
                        isvalid = false;
                    }
                    else if (data.d == "-1") {
                        $(element).next("span").text('SQL Error');
                        isvalid = false;
                    }
                    else {
                        $(element).next("span").text('Error');
                        isvalid = false;
                    }

                },
                error: function () {
                    alert('Problem');
                    isvalid = false;
                }
            });
        }
        if (classname.indexOf("phoneno") != -1) {
            var numpattern = /^\d{8,12}$/;
            if (value.match(numpattern)) {
                $(element).next("span").text('');
            }
            else {
                $(element).next("span").text('Invalid Number');
                isvalid = false;
            }
        }
        if (classname.indexOf("email") != -1) {
            //verify email start
            var pattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
            if (value.match(pattern)) {
                $(element).next("span").text('');
                if (classname.indexOf("emaildb") != -1) {
                    $.ajax({
                        type: "post",
                        url: "Default5.aspx/checkBomEmail",
                        data: "{emaiId:'" + value + "'}",
                        async: false,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            if (data.d == "2") {
                                $(element).next("span").text('');
                            }
                            else if (data.d == "1") {
                                $(element).next("span").text('Purchased Already');
                                isvalid = false;
                            }
                            else if (data.d == "0") {
                                $(element).next("span").text('Not Exist in Bom Tv');
                                isvalid = false;
                            }
                            else if (data.d == "-1") {
                                $(element).next("span").text('SQL Error');
                                isvalid = false;
                            }
                            else {
                                $(element).next("span").text('Error');
                                isvalid = false;
                            }

                        },
                        error: function () {
                            alert('Problem');
                            isvalid = false;
                        }
                    });
                }
            }
            else {
                $(element).next("span").text('Invalid Email');
                isvalid = false;
            }
            //verify email end
        }
    }
    return isvalid;
}
       
    </script>

Friday, November 2, 2012

send email using my domain

private static int sendemail(string bomEmailId, int customerId, string userName)
    {
        int ismailsend = 0;
        StringBuilder stringbuilder = new StringBuilder();
        MailAddress to = new MailAddress(bomEmailId);
        MailAddress from = new MailAddress("shoping@indiashoponline.com");
        MailMessage mailMessage = new MailMessage(from, to);
        System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential();
        //SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
        SmtpClient smtpClient = new SmtpClient("mail.indiashoponline.com");
        stringbuilder.Append("")
         .Append("")
         .Append("")
         .Append("")
         .Append("")
         .Append("
Dear, ").Append(userName).Append("
This is a online purchase confirmation mail from indiashoponline for the product and your shopping id is").Append(customerId).Append(".
In the case of any issue you can you can contact indiashoponline with your shopping id.And thank you for purchasing with us.
Best Regards...
Thank you for using indiashoponline.
phone:..................
)"); try { networkCredential.UserName = "sdfsdf@indiashoponline.com";//need to add valid user id networkCredential.Password = "sdfsdf";// need to add valid password //smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = false; // your domain smtpClient.Credentials = networkCredential; mailMessage.Subject = "Shopping @ IndiaShopOnline"; mailMessage.IsBodyHtml = true; mailMessage.Body = stringbuilder.ToString(); smtpClient.Send(mailMessage); ismailsend = 1; } catch (Exception ex) { ismailsend = 0; string error= ex.Message; } finally { mailMessage = null; networkCredential = null; smtpClient = null; } return ismailsend; }

send email using google apps

 private static int sendemail(string bomEmailId, int customerId, string userName)
    {
        int ismailsend = 0;
        StringBuilder stringbuilder = new StringBuilder();
        MailAddress to = new MailAddress(bomEmailId);
        MailAddress from = new MailAddress("shoping@indiashoponline.com");
        MailMessage mailMessage = new MailMessage(from, to);
        System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential();
        SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
        //SmtpClient smtpClient = new SmtpClient("mail.indiashoponline.com");
        stringbuilder.Append("")
         .Append("")
         .Append("")
         .Append("")
         .Append("")
         .Append("
Dear, ").Append(userName).Append("
This is a online purchase confirmation mail from indiashoponline for the product and your shopping id is").Append(customerId).Append(".
In the case of any issue you can you can contact indiashoponline with your shopping id.And thank you for purchasing with us.
Best Regards...
Thank you for using indiashoponline.
phone:..................
)"); try { networkCredential.UserName = "shopping@gmail.com";//need to add valid user id networkCredential.Password = "sdfsdfsdf";// need to add valid password smtpClient.EnableSsl = true; //smtpClient.UseDefaultCredentials = false; // your domain smtpClient.Credentials = networkCredential; mailMessage.Subject = "Shopping @ IndiaShopOnline"; mailMessage.IsBodyHtml = true; mailMessage.Body = stringbuilder.ToString(); smtpClient.Send(mailMessage); ismailsend = 1; } catch (Exception ex) { ismailsend = 0; string error= ex.Message; } finally { mailMessage = null; networkCredential = null; smtpClient = null; } return ismailsend; }

Wednesday, October 31, 2012

Ms Sql Transation

CREATE PROCEDURE [dbo].[usp_savePurchaseDetails](
@customerId varchar(50),
@productId varchar(50),
@userName varchar(50),
@bomEmailId varchar(50),
@amazonId varchar(50),
@phoneNumber varchar(50),
@status smallint,
@firstName varchar(50),
@middleName varchar(50),
@lastName varchar(50),
@homeName varchar(50),
@street varchar(50),
@city varchar(50),
@state varchar(50),
@country varchar(50),
@zipCode varchar(50),
@mobile varchar(50),
@homePhone varchar(50)
)
AS
BEGIN
 BEGIN TRANSACTION
 INSERT INTO BomAmazonCustomers (customerId,productId,userName,bomEmailId,phoneNumber,amazonId,purchasedDate,status)
 VALUES (@customerId,@productId,@userName,@bomEmailId,@phoneNumber,@amazonId, GETDATE(),@status)
  IF @@ERROR = 0 
  BEGIN
   INSERT INTO bomAmazonCustomersAddress (bomEmailId,firstName,middleName,lastName,houseName,street,city,state,country,zipCode,mobile,homePhone)
   VALUES (@bomEmailId,@firstName,@middleName,@lastName,@homeName,@street,@city,@state,@country,@zipCode,@mobile,@homePhone)
    IF @@ERROR = 0 
     BEGIN
       COMMIT TRANSACTION
     END
    ELSE
   BEGIN
    ROLLBACK TRANSACTION
    RETURN
   END
  END
  ELSE
  BEGIN
   ROLLBACK TRANSACTION
   RETURN
  END
END

Monday, October 29, 2012

unique radom string

  private static string uniquestring(string bomEmailId)
    {
        using (MD5 md5 = MD5.Create())
        {
           //byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(bomEmailId));
            byte[] array = Encoding.ASCII.GetBytes(bomEmailId);
            Guid result = new Guid(array);
            return result.ToString();
        }
    }

Saturday, October 27, 2012

custom jquery validation

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css" type="text/css" rel="Stylesheet" />
    <script type="text/javascript" language="javascript">
           function customvalidation(element) {
            isvalid = true;
            var classname = $(element).attr('class');
            var value = $(element).val();
            if (classname.indexOf("optional") == -1 && value == "") {
                $(element).next("span").text('Field Required');
                isvalid = false;
            }
            else {
                $(element).next("span").text('');
                if (classname.indexOf("phoneno") != -1) {
                    var numpattern = /^\d{8,12}$/;
                    if (value.match(numpattern)) {
                        $(element).next("span").text('');
                    }
                    else {
                        $(element).next("span").text('Invalid  Number');
                        isvalid = false;
                    }
                }
                if (classname.indexOf("email") != -1) {
                    //verify email start
                    var pattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
                    if (value.match(pattern)) {
                        $(element).next("span").text('');
                        if (classname.indexOf("emaildb") != -1) {
                            $.ajax({
                                type: "post",
                                url: "Default5.aspx/checkEmail",
                                data: "{emaiId:'" + value + "' }",
                                async: false,
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) {
                                    if (data.d == "2") {
                                        $(element).next("span").text('');
                                    }
                                    else if (data.d == "1") {
                                        $(element).next("span").text('Purchased Already');
                                        isvalid = false;
                                    }
                                    else if (data.d == "0") {
                                        $(element).next("span").text('Not Exist in Bom Tv');
                                        isvalid = false;
                                    }
                                    else if (data.d == "-1") {
                                        $(element).next("span").text('SQL Error');
                                        isvalid = false;
                                    }
                                    else {
                                        $(element).next("span").text('Error');
                                        isvalid = false;
                                    }

                                },
                                error: function () {
                                    alert('Problem');
                                    isvalid = false;
                                }
                            });
                        }
                    }
                    else {
                        $(element).next("span").text('Invalid Email');
                        isvalid = false;
                    }
                    //verify email end
                }
            }
            return isvalid;
        }
        $(document).ready(function () {
            $('#purchasetable').dialog({ autoOpen: false, modal: true, title: "Enter Purchase Details", width: 600, resizable: false });
            $('#userdetails').dialog({ autoOpen: false, modal: true, title: "Enter User Details", width: 700, resizable: false });

            $("#purchasetable :input").blur(function () {
                var element = $(this);
                customvalidation(element);
            });
            $("#userdetails :input").blur(function () {
                var element = $(this);
                customvalidation(element);
            });
            $("#Purchasebtn").click(function () {
                var invalidcount = 0;
                $("#purchasetable :input[type=text]").each(function (index, element) {
                    if (customvalidation(element) == false)
                        invalidcount = invalidcount + 1;
                });
                if (invalidcount == 0) {
                    $('#userdetails').dialog('open');
                    $('.ui-widget-overlay').click(function () {
                        $('#userdetails').dialog('close');
                    });
                }
            });
            $("#PurchaseCompletebtn").click(function () {
                var invalidcount2 = 0;
                $("#userdetails :input[type=text]").each(function (index, element) {
                    if (customvalidation(element) == false)
                        invalidcount2 = invalidcount2 + 1;
                });
                alert(invalidcount2);
                if (invalidcount2 == 0) {
                    $.ajax({
                        type: "post",
                        url: "Default5.aspx/saveUserDetails",
                        data: "{productId:'productxt',userName:'" + $("#nametxt").val() + "',bomEmailId:'" + $("#bomEmailtxt").val() + "',amazonEmailId:'" + $("#amazonEmailtxt").val() + "',phoneNumber:'" + $("#phoneNumbertxt").val() + "',firstName:'" + $("#firstNametxt").val() + "',middleName:'" + $("#middleNametxt").val() + "',lastName:'" + $("#lastNametxt").val() + "',homeName:'" + $("#houseNametxt").val() + "',street:'" + $("#streettxt").val() + "',city:'" + $("#citytxt").val() + "',state:'" + $("#statetxt").val() + "',country:'" + $("#countrytxt").val() + "',zipCode:'" + $("#ziptxt").val() + "',mobile:'" + $("#mobiletxt").val() + "',homePhone:'" + $("#homePhonetxt").val() + "'}",
                        async: false,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            if (data.d = "1") {
                                alert('Complete Process');
                                $('#purchasetable').dialog('close');
                                $('#userdetails').dialog('close');
                            }
                        },
                        error: function () {
                            alert('Problem');
                        }
                    });
                }
            });
        });
        function purchasepopup() {
            $('#purchasetable').dialog('open');
            $('.ui-widget-overlay').click(function () { $('#purchasetable').dialog('close'); });
        }
        
    </script>

Friday, October 26, 2012

Jquery Custom Validation Function

 $("#form1").validate({
                rules: {
                    txtemail: {
                        //start txtemail
                        required: true, email: true,
                        newpattern: function () {
                            var pattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
                            var email = $("#emailId").val();
                            if (email.match(pattern)) {
                                $.ajax({
                                    type: "post",
                                    url: "Default2.aspx/checkEmail",
                                    data: "{emaiId:'" + email + "' }",
                                    async: false,
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json",
                                    success: function (data) {
                                        $("#form1").submit(function () {
                                            if (data.d == 1) {
                                                $.ajax({
                                                    type: "post",
                                                    url: "Default2.aspx/saveUserDetails",
                                                    data: "{emaiId:'abcd1234' }",
                                                    async: false,
                                                    contentType: "application/json; charset=utf-8",
                                                    dataType: "json",
                                                    success: function (data) {
                                                        return true;
                                                    },
                                                    error: function () {
                                                        alert('Problem');
                                                    }
                                                });
                                            }
                                            else
                                                return false;
                                        });
                                    },
                                    error: function () {
                                        alert('Problem');
                                    }
                                });
                            }
                        }
                        //ends txtemail
                    },
                    txtFirstName: {
                        required: true
                    }

                },
                messages: {
                    txtemail: {
                        required: "Email Requrid", email: "Enter a valid Email Addres"
                    },
                    txtFirstName: {
                        required: "First Name Required"
                    }
                }
            });

jquery pop up validation

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $("#player").detach().appendTo("body").click(function () {
            $('#form1').dialog('open');
            return false;
        });
        $('#form1').dialog({
            autoOpen: false,
            modal: true,
            title: "RFMD Video",
            width: 500,
            resizable: false,
            buttons: {
                "Validate": function () {
                    $("#form1").submit();
                }
            }
        });

        // $("#").validate();

        $("#form1").validate({
            rules: {
                field: {
                    required: true, email: true
                }
            }
        });
    });
    </script>




 <a href="#" id="player">Click to play</a>
    <div id="videoPlayerDiv">
   <input class="left" id="field" name="field" />
    <br/>
  <input type="submit" value="Validate!" />
    </div>

Jquery Validation

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $('#videoPlayerDiv').dialog({ autoOpen: false, modal: true, title: "RFMD Video", width: 500, resizable: false });

        // $("#").validate();

        $("#form1").validate({
            rules: {
                field: {
                    required: true,
                    email: true
                }
            }
        });

    });
    function SetVideo() {
         $('#videoPlayerDiv').dialog('open');
        $('.ui-widget-overlay').click(function () { $('#videoPlayerDiv').dialog('close'); });
    };
    </script>




 <div id="Div1" style="display:block">
   <input class="left" id="field" name="field" />
    <br/>
  <input type="submit" value="Validate!" />
</div>

jquery tabs


    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css" type="text/css" rel="Stylesheet" />
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $("#mytab").tabs();
    });
    </script>


<div id="mytab" style="display:block">
<ul>
        <li><a href="#tabs-1">Step 1</a></li>
        <li><a href="#tabs-2">Step 2</a></li>
        <li><a href="#tabs-3">Step 3</a></li>
    </ul>
    <div id="tabs-1">
        <input type="text" class="required" name="step1" id="step1" />
    </div>
    <div id="tabs-2">
        <input type="text" class="required" name="step2" id="step2" />
    </div>
    <div id="tabs-3">
        <input type="text" class="required" name="step3" id="step3" />
        <input type="submit" name="submit" value="Submit" />
    </div> 
        </div>  

Thursday, October 25, 2012

Jquery Popup

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $('#mypopup').dialog({ autoOpen: false, modal: true, title: "my pop up window", width: 500, resizable: false });
    });
    function popup() {
        $('#mypopup').dialog('open');
        $('.ui-widget-overlay').click(function () { $('#mypopup').dialog('close'); });
    };
    </script>


<a href="#" onclick="javascript:popup('');return false;">Click to play</a>
    <div id="mypopup">
        <input id="abc"  />
    </div>

Category