Asp.net Migration into 4.5.2


In asp.net application migration from low level version into 4.5.2 version.

First requirement tools

1.OS about Windows 7 sp1, Windows 8, server 2012

2.Visual studio 2013 (Language tools 4.5.2 Download and install it.NDP452-KB2901951-x86-x64-DevPack)

3. Sql Server 2008.

 

 

wordpress install url


http://www.wikihow.com/Install-Wordpress-on-XAMPP

http://make.wordpress.org/core/handbook/installing-a-local-server/installing-xampp/

http://wpmu.org/install-wordpress-locally-on-windows-with-xampp/

Validate_javascript


<scriptlanguage=”javascript”type=”text/javascript”>
function
validate()
{
      if (document.getElementById(“<%=txtName.ClientID%>”).value==“”
)
{
                 alert(“Name Feild can not be blank”
);
document.getElementById(
“<%=txtName.ClientID%>”
).focus();
                 returnfalse
;
}
      if(document.getElementById(“<%=txtEmail.ClientID %>”).value==“”
)
{
alert(
“Email id can not be blank”
);
                document.getElementById(“<%=txtEmail.ClientID %>”
).focus();
                returnfalse
;
}
     var
emailPat = /^(\”.*\”|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
     var emailid=document.getElementById(“<%=txtEmail.ClientID %>”
).value;
     var
matchArray = emailid.match(emailPat);
     if (matchArray == null
)
{
alert(
“Your email address seems incorrect. Please try again.”
);
document.getElementById(
“<%=txtEmail.ClientID %>”
).focus();
               returnfalse
;
}
    if(document.getElementById(“<%=txtWebURL.ClientID %>”).value==“”
)
{
alert(
“Web URL can not be blank”
);
document.getElementById(
“<%=txtWebURL.ClientID %>”).value=
http://&#8221;
               document.getElementById(“<%=txtWebURL.ClientID %>”
).focus();
               returnfalse
;
}
    var Url=
“^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$”
    var tempURL=document.getElementById(“<%=txtWebURL.ClientID%>”
).value;
    var
matchURL=tempURL.match(Url);
     if(matchURL==null
)
{
alert(
“Web URL does not look valid”
);
document.getElementById(
“<%=txtWebURL.ClientID %>”
).focus();
               returnfalse
;
}
     if (document.getElementById(“<%=txtZIP.ClientID%>”).value==“”
)
{
alert(
“Zip Code is not valid”
);
document.getElementById(
“<%=txtZIP.ClientID%>”
).focus();
               returnfalse
;
}
     var digits=“0123456789”
;
     var
temp;
     for (var i=0;i<document.getElementById(“<%=txtZIP.ClientID %>”
).value.length;i++)
{
temp=document.getElementById(
“<%=txtZIP.ClientID%>”
).value.substring(i,i+1);
               if
(digits.indexOf(temp)==-1)
{
alert(
“Please enter correct zip code”
);
document.getElementById(
“<%=txtZIP.ClientID%>”
).focus();
                        returnfalse
;
}
}
     returntrue
;
}
</script>

File Upload


database:

id int

filename varchar(50),

filepath varchar(100)

 

Then create one Image folder in ur project.

<div>

    <asp:FileUpload ID=”FileUpload1″ runat=”server”/>

    <asp:Button ID=”btnUpload” runat=”server” Text=”Upload”

        OnClick=”btnUpload_Click” />

</div>

 

<connectionStrings>

  <add name=”conString”

     connectionString=”Data Source=.\SQLEXPRESS;database=GridDB;

       Integrated Security=true”/>

</connectionStrings >

 

protected void btnUpload_Click(object sender, EventArgs e)

{

    if (FileUpload1.PostedFile != null)

    {

        string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName); 

 

        //Save files to disk

        FileUpload1.SaveAs(Server.MapPath(“images/” +  FileName));

 

        //Add Entry to DataBase

        String strConnString = System.Configuration.ConfigurationManager

            .ConnectionStrings[“conString”].ConnectionString;

        SqlConnection con = new SqlConnection(strConnString);

        string strQuery = “insert into tblFiles (FileName, FilePath)” +

            ” values(@FileName, @FilePath)”;

        SqlCommand cmd = new SqlCommand(strQuery);

        cmd.Parameters.AddWithValue(“@FileName”, FileName);

        cmd.Parameters.AddWithValue(“@FilePath”, “images/” + FileName); 

        cmd.CommandType = CommandType.Text;

        cmd.Connection = con;

        try

        {

            con.Open();

            cmd.ExecuteNonQuery();

        }

        catch (Exception ex)

        {

            Response.Write(ex.Message);

        }

        finally

        {

            con.Close();

            con.Dispose();

        }

    }

}

 

<div>

<br />

    <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns = “false”

       Font-Names = “Arial” >

    <Columns>

       <asp:BoundField DataField = “ID” HeaderText = “ID” />

       <asp:BoundField DataField = “FileName” HeaderText = “Image Name” />

       <asp:ImageField DataImageUrlField=”FilePath” ControlStyle-Width=”100″

        ControlStyle-Height = “100” HeaderText = “Preview Image”/>

    </Columns>

    </asp:GridView>

</div>

 

protected void Page_Load(object sender, EventArgs e)

{

    DataTable dt = new DataTable();

    String strConnString = System.Configuration.ConfigurationManager.

        ConnectionStrings[“conString”].ConnectionString;

    string strQuery = “select * from tblFiles order by ID”;

    SqlCommand cmd = new SqlCommand(strQuery);

    SqlConnection con =  new SqlConnection(strConnString);

    SqlDataAdapter sda = new SqlDataAdapter();

    cmd.CommandType = CommandType.Text;

    cmd.Connection = con;

    try

    {

        con.Open();

        sda.SelectCommand = cmd;

        sda.Fill(dt);

        GridView1.DataSource = dt;

        GridView1.DataBind(); 

    }

    catch (Exception ex)

    {

        Response.Write(ex.Message);

    }

    finally

    {

        con.Close();

        sda.Dispose();

        con.Dispose();

    }

}

 

Another sample with download link:

 

<asp:GridView ID=”gvDetails” CssClass=”Gridview” runat=”server” AutoGenerateColumns=”false” DataKeyNames=”FilePath”>
<HeaderStyle BackColor=”#df5015″ />
<Columns>
<asp:BoundField DataField=”Id” HeaderText=”Id” />
<asp:BoundField DataField=”FileName” HeaderText=”FileName” />
<asp:TemplateField HeaderText=”FilePath”>
<ItemTemplate>
<asp:LinkButton ID=”lnkDownload” runat=”server” Text=”Download” OnClick=”lnkDownload_Click”></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
 
protected void lnkDownload_Click(object sender, EventArgs e)
{
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString();
Response.ContentType = “image/jpg”;
Response.AddHeader(“Content-Disposition”, “attachment;filename=\”” + filePath + “\””);
Response.TransmitFile(Server.MapPath(filePath));
Response.End();
}

column splited


<div class="row">
  <div class="columns twelve">
    <h2>Twelve Columns</h2>
    <p>Lorem ipsum...</p>
  </div>
</div>
<div class="row">
    <div class="twelve columns">
        <img src="http://placehold.it/1000x400&text=img" alt="">
    </div>
</div>
<div class="row">
  <div class="eight columns">
    <h2>Eight Columns</h2>
    <p>Lorem ipsum...</p>
  </div>
  <div class="four columns">
    <h2>Four Columns</h2>
    <p>Lorem ipsum...</p>
  </div>
</div>
<div class="row">
  <div class="three columns">
    <h3>Three Columns</h3>
    <p>Lorem ipsum...</p>
  </div>
  <div class="three columns">
    <h3>Three Columns</h3>
    <p>Lorem ipsum...</p>
  </div>
    
  <div class="three columns">
    <h3>Three Columns</h3>
    <p>Lorem ipsum...</p>
  </div>
  <div class="three columns">
    <h3>Three Columns</h3>
    <p>Lorem ipsum...</p>
  </div>
</div>
<div class="row">
  <div class="eight columns">
    <h2>Eight Columns</h2>
    <p>Lorem ipsum...</p>
  </div>
  <div class="four columns">
    <h2>Four Columns</h2>
    <p>Lorem ipsum...</p>
  </div>
</div>

ve Demo

As you can see, we used a lot of different column variations here. We’ve got divs that span all twelve columns, including one with an image, and others that only span three. It all comes together into a beautiful and simple layout. Check out the demo below to see it live.

Demo: Click here to launch.

screenshot

Ajax calender


<tr>
<th>Example III</th>
<td>
<span id=”exampleIII”>
<input name=”day” type=”text” style=”width: 18px; border-width: 1px 0 1px 1px;” maxlength=”2″ />
<input value=”/” type=”text” style=”width: 5px; border-width: 1px 0 1px 0;” disabled=”disabled” />
<input name=”month” class=”textbox” type=”text” style=”width: 16px; border-width: 1px 0 1px 0;” maxlength=”2″ />
<input value=”/” type=”text” style=”width: 5px; border-width: 1px 0 1px 0;” disabled=”disabled” />
<input name=”year” type=”text” style=”width: 28px; border-width: 1px 0 1px 0;” maxlength=”4″ />
<input type=”text” style=”width: 15px; border-width: 1px 1px 1px 0;” disabled=”disabled” />
<img src=”images/calendar.gif” id=”togglePicker” class=”pickerImg” width=”13px” height=”12px” alt=”” />
</span>
</td>
</tr>

 

css….

 

.pickerImg {
position: absolute;
margin-left: -16px;
margin-top: 5px;
cursor: pointer;
}

 

 

javascript

window.addEvent(‘domready’, function()

new vlaDatePicker(‘exampleIII’, { openWith: ‘togglePicker’, offset: { y: -2, x: 2 }, separateInput: { day: ‘day’, month: ‘month’, year: ‘year’ } });

}

URLS


URLS

AJAX Controls

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Default.aspx

JQUERY example:

Login Box Modal Dialog Window with CSS and jQuery

http://www.jquery4u.com/windows/10-jquery-popup-window-image-slider-plugins/

CSS:

Add Active Navigation Class Based on URL

Javascrip with jquery…JQUERY DEMO


<style type=”text/css”>
body{
background:#202020;
font:bold 12px Arial, Helvetica, sans-serif;
margin:0;
padding:0;
min-width:960px;
color:#bbbbbb;
}

#mask {
display: none;
background: #000;
position: fixed; left: 0; top: 0;
z-index: 10;
width: 100%; height: 100%;
opacity: 0.8;
z-index: 999;
}

.login-popup{
display:none;
background: #333;
padding: 10px;
border: 2px solid #ddd;
float: left;
font-size: 1.2em;
position: fixed;
top: 50%; left: 50%;
z-index: 99999;
box-shadow: 0px 0px 20px #999;
-moz-box-shadow: 0px 0px 20px #999; /* Firefox */
-webkit-box-shadow: 0px 0px 20px #999; /* Safari, Chrome */
border-radius:3px 3px 3px 3px;
-moz-border-radius: 3px; /* Firefox */
-webkit-border-radius: 3px; /* Safari, Chrome */
}

img.btn_close {
float: right;
margin: -28px -28px 0 0;
}

fieldset {
border:none;
}

form.signin .textbox label {
display:block;
padding-bottom:7px;
}

form.signin .textbox span {
display:block;
}

form.signin p, form.signin span {
color:#999;
font-size:11px;
line-height:18px;
}

form.signin .textbox input {
background:#666666;
border-bottom:1px solid #333;
border-left:1px solid #000;
border-right:1px solid #333;
border-top:1px solid #000;
color:#fff;
border-radius: 3px 3px 3px 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
font:13px Arial, Helvetica, sans-serif;
padding:6px 6px 4px;
width:200px;
}

//////////////////////////

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js”></script&gt;
<script type=”text/javascript”>
$(document).ready(function() {
$(‘a.login-window’).click(function() {

// Getting the variable’s value from a link
var loginBox = $(this).attr(‘href’);

//Fade in the Popup and add close button
$(loginBox).fadeIn(300);

//Set the center alignment padding + border
var popMargTop = ($(loginBox).height() + 24) / 2;
var popMargLeft = ($(loginBox).width() + 24) / 2;

$(loginBox).css({
‘margin-top’ : -popMargTop,
‘margin-left’ : -popMargLeft
});

// Add the mask to body
$(‘body’).append(‘<div id=”mask”></div>’);
$(‘#mask’).fadeIn(300);

return false;
});

// When clicking on the button close or the mask layer the popup closed
$(‘a.close, #mask’).live(‘click’, function() {
$(‘#mask , .login-popup’).fadeOut(300 , function() {
$(‘#mask’).remove();
});
return false;
});
});
</script>

/////////////

 

<div class=”container”>
<div id=”content”>

<div class=”post”>
<h2>Your Login or Sign In Box</h2>
<div class=”btn-sign”>
<a href=”#login-box” class=”login-window”>Login / Sign In</a>
</div>
</div>

<div id=”login-box” class=”login-popup”>
<a href=”#” class=”close”><img src=”close_pop.png” class=”btn_close” title=”Close Window” alt=”Close” /></a>
<form method=”post” class=”signin” action=”#”>
<fieldset class=”textbox”>
<label class=”username”>
<span>Username or email</span>
<input id=”username” name=”username” value=”” type=”text” autocomplete=”on” placeholder=”Username”>
</label>

<label class=”password”>
<span>Password</span>
<input id=”password” name=”password” value=”” type=”password” placeholder=”Password”>
</label>

<button class=”submit button” type=”button”>Sign in</button>

<p>
<a class=”forgot” href=”#”>Forgot your password?</a>
</p>

</fieldset>
</form>
</div>

JAVASCRIPT


Email Validation:

function ValidateEmail()
{
var uemail = document.registration.email;
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
document.registration.desc.focus();
return true;
}
else
{
alert(“You have entered an invalid email address!”);
uemail.focus();
return false;
}
}

All Numeric(pincode &phone)

function allnumeric()
{
var uzip = document.registration.zip;
var numbers = /^[0-9]+$/;
if(uzip.value.match(numbers))
{
// Focus goes to next field i.e. email.
document.registration.email.focus();
return true;
}
else
{
alert(‘ZIP code must have numeric characters only’);
uzip.focus();
return false;
}
}

All Letter(username)

function allLetter()
{
var uname = document.registration.username;
var letters = /^[A-Za-z]+$/;
if(uname.value.match(letters))
{
// Focus goes to next field i.e. Address.
document.registration.address.focus();
return true;
}
else
{
alert(‘Username must have alphabet characters only’);
uname.focus();
return false;
}
}

Password Length

function passid_validation(mx,my)
{
var passid = document.registration.passid;
var passid_len = passid.value.length;
if (passid_len == 0 ||passid_len >= my || passid_len < mx)
{
alert(“Password should not be empty / length be between “+mx+” to “+my);
passid.focus();
return false;
}
// Focus goes to next field i.e. Name.
document.registration.username.focus();
return true;
}

http://www.w3resource.com/javascript/form/javascript-validation-download.php

HTML & PHP


<form name="contactform" method="post" action="send_form_email.php">
<table width="450px">
<tr>
 <td valign="top">
  <label for="first_name">First Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="first_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top"">
  <label for="last_name">Last Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email Address *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="telephone">Telephone Number</label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="comments">Comments *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>
</tr>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit">   <a href="http://www.freecontactform.com/email_form.php">Email Form</a>
 </td>
</tr>
</table>
</form>
php
<?php
if(isset($_POST['email'])) {
    
    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "you@yourdomain.com";
    $email_subject = "Your email subject line";
    
    
    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }
    
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');      
    }
    
    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // required
    
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.\n\n";
    
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
    
    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Telephone: ".clean_string($telephone)."\n";
    $email_message .= "Comments: ".clean_string($comments)."\n";
    
    
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>