ASP.NET vNext on OSX and Linux

Original post/curtsy: http://graemechristie.github.io/graemechristie/blog/2014/05/26/asp-dot-net-vnext-on-osx-and-linux/

So what is ASP.NET vNext ?

Microsoft have recently released a preview of the next iteration of their ASP.NET platform. I’m not going to go into the details here, people like Scott Hanselman have already done a fantastic job of that. I will however say that the changes, both technical and cultural, are huge. Two of those changes are particularly relevant to this blog post.

Firstly, ASP.NET vNext is fully open source. People like you and me are able to get in on the ground floor, try out the bits and pieces and even contribute – pretty much from the project’s inception.

Secondly, ASP.NET vNext is cross platform, and embraces non Windows hosts as first class citizens. Microsoft are fully integrating Mono and Linux into their build environment and test matrix, and are actively working with the community to make Mono a top class platform for hosting ASP.NET. That being said, these are early days, and the team is still ironing out issues with the Mono environment.

Getting ASP.NET vNext up and running on OSX and Linux

There are two main steps to getting to the point where we can run ASP.NET vNext applications on our non Windows system.

The first is to install Mono. Normally this would be a no brainer; however as all this stuff is very shiny and new there are fixes and features that are currently only in the bleeding edge source code of Mono and have not been released as a package as yet. In order to get these fixes we are going to need to build mono from the latest source code located in the mono git repository.

The second step is to install the “K Runtime Environment” or KRE. This is the command line environment that will build and run (not that there is really a distinction anymore) projects from their new project.json project files.

Installation of the KRE is handled by the “K Version Manager” (KVM). This is a simple app that can install multiple versions of the KRE side by side, and allow you to easily switch between them.

Building Mono

I don’t want to go into too much detail here. There are plenty of guides around the internet on installing mono from source.

  • Install Mono as per the instructions at The Mono Github page.
  • You will need an earlier mono release installed in order to build Mono from source (Mono uses Mono to build itself)
  • You will need autoconf, libtool and and a few other common dev tools installed on your system.
  • On some linux systems you may need to run the following before you run the mozroots command below.
1
2
3
 sudo certmgr -ssl -m https://go.microsoft.com
 sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
 sudo certmgr -ssl -m https://nuget.org
  • If you are on linux, you will need to run mozroots --import --sync after installing mono to avoid certificate/trust issues down the line
  • If you are on OSX you will want to edit /private/etc/paths and move the line /usr/local/bin before the line /usr/bin so the system finds the new mono version on the path before the old one.

caveat: This may totally break your system if you have lots of crazy stuff in /usr/local/bin. If your not sure about this, wait for a supported official release of Mono

Once all this is done, run mono --version. You should see that you are running Mono version 3.4.1 or newer.

mono --version

If you do not, check your $PATH variable and go back over the mono install steps.

Installing KVM and the K Runtime Environment

Installing KVM is super simple. If you like you can go to the Readme for the AspNet Home project and follow the “Getting Started” instructions there, however that involves cloning the Home Repository which is only required for that quick start demo.

KVM can be installed on any Linux or OSX system (that has bash or zsh and curl installed) with a single line.

1
curl https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.kre/kvm/kvm.sh && kvm upgrade

This will:

  • download kvm.sh and save it in ~/.kre/kvm/kvm.sh
  • add the command to run kvm.sh on every login to bash/zsh.
  • kvm.sh will then be run via the source command. This adds the kvm command to the current shell.
  • run kvm upgrade. This will download the latest KRE package, extract it to .kre/packages and add the bin folder to your path.

Once this is done, all of the KRE commands will be available from shell prompt. Primarily this will be the k command used to run ASP.NET vNext Projects, and the kpm command used to restore packages.

Additionally the kvm command can be used to install other version of KRE side by side for the user, switch between versions, list the installed versions and set up aliases. See the ASP.NET Home Project Readme for examples of the various kvm commands.

Okay, so I’ve got a Shiny New KRE ….

So let’s point it at something. We could download one of the many samples from the aspnet repository, however just to prove we have everything we need to build and run ASP.NET vNext apps on OSX and Linux, lets create a very basic project from scratch.

  • Create a folder called HelloKRuntime somewhere on your system and cd into that folder
  • Create a file called project.json and copy the following text into it. This is your ASP.NET vNext project file .. and not an angle bracket to be seen !
1
2
3
4
5
6
7
8
9
  {
    "dependencies": {
      "System.Console": "4.0.0.0"
    },
    "configurations": {
      "net45": {},
      "k10": {}
    }
  }
  • Create a file called Program.cs and copy the following text into it.
1
2
3
4
5
6
7
8
9
  using System;

  public class Program
  {
      public static void Main()
      {
          Console.WriteLine("Hello K Runtime !");
      }
  }
  • type kpm restore -s https://www.myget.org/F/aspnetvnext/ The K Package Manager will head off to the nuget repository and fetch System.Console and all its dependencies, based on the entry in your project.json file. Note that there is no need to use Nuget to install this package. The project.json entry is all the info kpm needs to fetch your dependencies.

Note: Because the ASP.NET vNext project is currently using their own nuget feed, we need to supply the nuget source on the command line. This can be provided in a NuGet.Config file in your Solution folder, and once the vNext is released you shouldn’t need one at all unless you are using your own private nuget feeds.

kpm restore

  • Now type k run from the command line. You should see your system burst to life and utter those immortal words

Hello K Runtime

  • As an example of how the new Configuration system ties into the environment, try typing export KRE_TRACE=1 and then k run again. You will see the compiler output as well as the “Hello K Runtime” message.

Hello Compiler Output

In Summary

Hopefully this post has demonstrated that cross platform ASP.NET vNext functionality is available now. There are still rough edges, but progress is being made daily and first class support for OSX and Linux environments is on the horizon. If you are having issues getting this working, feel free to drop into the aspnetvnext room on Jabbr and someone should be able to help you out.

UPDATE: If you’d like to try something more involved than the trivial console application above, the simple Hello World V Next web example might be a good next step.

The Next Generation of .NET – ASP.NET vNext

Original post/ curtsy: https://blogs.msdn.microsoft.com/dotnet/2014/05/12/the-next-generation-of-net-asp-net-vnext/

The Next Generation of .NET – ASP.NET vNext

Updated (July 2015): See Announcing .NET Framework 4.6 to read about the latest version of the NET Framework.

Today at TechEd North America, we announced the latest set of innovations that are part of the next generation of .NET. The biggest of those is ASP.NET vNext, which is an updated version of ASP.NET that been optimized for cloud Web development. We’ve continued to improve the core .NET technologies that we shared at Build last month, specifically the .NET Native ahead-of-time compiler and the .NET Next Generation JIT (“RyuJIT”). Both have new releases you can try out. We also have a set of smaller announcements to share.

At Build last month, we announced the .NET Foundation. We are currently talking to over 25 community-based .NET projects and organizations about joining the foundation. The interest in the foundation has exceeded our expectations and is off to a great start.

We also announced the .NET Compiler Platform (“Roslyn”) at Build. It includes new C# and VB compilers and a preview of new language features being considered for C# 6. The project is open source on codeplex and has accepted its first pull requests from the community.

The final release of Visual Studio 2013 Update 2 is now available. Update 2 brings dozens of significant new features to Visual Studio developers, including tools for Windows Phone 8.1 and universal Windows apps.

While we’re looking forward, it’s also good to look at one of the current strengths of .NET. There are currently 1.8 billion active installs of .NET. That’s a very large number by any measure and a great base of desktop and server machines on which to run your apps.

TechEd .NET Announcements

Here’s a quick rundown of the .NET announcements that we shared at TechEd.

.NET vNext

TechEd is the first time we’re talking about .NET vNext, as the next major release of the .NET Framework. At Build and TechEd, we’ve shared many of the features and components that you can expect in the next release. You will be able to compile C# 6 and VB with the Roslyn compilers, host ASP.NET vNext apps on the server or cloud, compile your Windows Store apps with the .NET Native ahead of time compiler, and enjoy faster desktop and server apps with the Next Generation JIT.

We’ve optimized .NET for the mobile-first and cloud-first development options that have become more common today. Device and cloud apps come with significant user expectations around performance, and also run in more specialized hardware/virtual environments. For Windows Store apps, we built the .NET native ahead of time compiler. For cloud apps, we’ve developed a cloud optimized mode.

.NET vNext will have a cloud optimized mode that enables you to deploy your apps with a copy of the .NET Framework libraries they need. Since the runtime and framework libraries are deployed on an app-basis, each app can run different versions of .NET vNext side-by-side and upgrade separately, all on the same machine. These libraries have been slimmed down significantly to reduce the footprint of the framework, and will be distributed via NuGet. Also, libraries such as WPF and Windows Forms have been removed from this mode.

We’re developing this with cross-platform in mind, including an active collaboration with Xamarin to ensure that cloud-optimized .NET applications can run on Mac or Linux on top of the Mono runtime. The great productivity of .NET and ASP.NET can be available to teams working in mixed development environments.

ASP.NET vNext

ASP.NET vNext is our big announcement at TechEd. We’ve updated many aspects of ASP.NET to make ASP.NET apps easier to build and perform significantly better. We’ve considered sites and services that get infrequent traffic and those that get bombarded by visitors all day long. We’ve also opened up new scenarios that were just not possible with ASP.NET before.

We’ve designed ASP.NET with a key set of design principles in mind:

  • Cloud-ready out of the box
  • A single programming model for Web sites and services
  • Low-latency developer experience
  • Make high-performance and high-productivity APIs and patterns available – enable them both to be used and compose together within a single app
  • Fine-grained control available via command-line tools and standard file formats
  • Delivered via NuGet
  • Release as open source via the .NET Foundation
  • Can run on Mono, on Mac and Linux

ASP.NET vNext includes updated versions of MVC, Web API, Web Pages, SignalR and EF. The key improvement with these frameworks is that MVC, Web API and Web Pages have been merged into a single programming model. For example, there’s now unified controller and routing concepts between all three. You can now have a single controller that returns both MVC views and formatted Web API responses, on the same HTTP verb.

ASP.NET vNext apps are cloud ready by design. Services such as session state and caching adjust their behavior depending on whether the app is running in the cloud or in a traditional hosting environment, while providing a consistent API. We use dependency injection behind the scenes to provide your app with the correct implementation for these services. Using this approach, it is really easy to move your app from on-premises to the cloud, since our code changes, not yours.

You will be able to make changes to your web applications and see the results after a browser refresh, with no separate build step needed. This significant productivity enhancement is based on improvements to load times in the underlying CLR, as well as use of the new .NET Compiler Platform (“Roslyn”).

You can see the ASP.NET vNext in action in the images below. The first image shows an ASP.NET vNext Hello World app hosted from the command-line and drive from browser. Any edits in Visual Studio will be compiled and executed when the browser is next refreshed. This app is using .NET vNext cloud optimized mode.

You can also use Visual Studio with a more traditional Visual Studio F5 workflow that automatically starts the webserver and launches the browser. This is the same app as shown in the image above.

In the image below, the app has been re-configured to run on the full .NET vNext framework, instead of the cloud optimized mode. That’s just a setting on the project. The app now has access to all of the APIs in the .NET Framework. The browser refresh feature is available in this configuration, too.

The table below outlines the ASP.NET vNext scenarios we’ve built and where they are available.

ASP.NET vNext Feature On .NET vNext On .NET vNext (Cloud Optimized)
Cloud Ready * *
Modular Design * *
Dependency Injection * *
Consistent Tracing / Debugging * *
Faster Development (browser refresh) * *
Open Source * *
Full Side by Side (runtime and framework
deployed with application)
*
Faster startup, Lower memory / Higher throughput (best of class) *
Uses a smaller set of framework libraries   *
Enabled on Mono, on Mac and Linux   *

 

ASP.NET vNext will be open source and will be contributed to the .NET Foundation. This shouldn’t come as a big surprise since the ASP.NET Web stack is already open source. All of ASP.NET vNext will be delivered via NuGet, will be open source and will take contributions. Read ASP.NET vNext: the future of .NET on the Server to learn more.

Our announcement at TechEd is the first stop for .NET vNext and ASP.NET vNext. We’ll share much more in the months to come before we release the final versions. We’re looking forward to shipping pre-release versions in order to get your feedback.

Additional .NET Framework Updates and Improvements

We recently announced the .NET Framework 4.5.2. It including significant improvements in ASP.NET and Windows Forms and other areas of the product. You can start incorporating 4.5.2 features into your apps now.

We released several key improvements to ASP.NET Web Forms. These include support for ASP.NET Identity 2.0, Entity DataSource control for Entity Framework 6 and Roslyn support.

We have also added new features and scenarios to both .NET Native and the Next Generation JIT. .NET Native now support x86, in addition to ARM and x64 apps. The Next Generation JIT now supports Windows 7 and later for x64 apps. Both of these technologies are a critical part of our .NET vNext roadmap. Expect to hear more about both of them in the coming months.

Targeting Multiple Platforms

We’ve been working for several years to make it easier to write code for multiple platforms, both as apps and libraries. We started by enabling our PCL reference assemblies for Xamarin, who quickly moved forward with that change. More recently, we’ve been working closely with Xamarin to make our .NET NuGet packages work better with Xamarin tools, to make it easier to build .NET apps for iOS and Android. There’s still work to do, but the experience has gotten much better and will continue to improve.

At TechEd, we announced a new portability analysis tool, called ApiPort. It provides you with two main pieces of data: the platforms that you can easily/reasonably target with your code, and the dependencies that are preventing you from targeting additional platforms.

The command line tool generates an Excel report that provides you with two views of its portability analysis. It provides a high-level color-coded view for a given set of platforms. It also provides a very detailed list of all the types and members used within your code, and whether they are supported, per platform. Given that the report is in Excel, it is very easy to filter the list, build pivot tables and do whatever else you want to perform further analysis.

The image below shows a small sample of the high-level portability analysis view. Only one assembly is shown, but there can be multiple. Check out this sample portability analysis to get a first-hand view.

The tool has another function, too. All of the dependency data (not the assemblies) are uploaded to an Azure service that the .NET team maintains. The data that the tool uploads is the list of assemblies and APIs that your code relies on. We do not record where the data came from or by whom. We do not upload any of your actual code or binaries. We want to know which functionality we need to bring to each platform to make it easier to target all platforms.

If you are finding it difficult to target a particular platform, please “vote” for the APIs you want added to a particular platform by running the tool on your app and libraries. It’s really easy to run the tool on a whole directory.

This first release of tool is missing a few features that we are in the process of adding. The Xamarin/Mono platforms are currently missing from the tool. It also doesn’t yet take into consideration NuGet packages that make .NET Framework APIs available on other platforms, counting them as missing APIs.

Client Libraries for Microsoft Services

You’ve probably heard that Microsoft is both a “services first” and “devices first” company. At the nexus of those statements are client libraries that make it easy to target Microsoft services from apps. While Client libraries for Microsoft services are not new, we are more recently working to provide support for more platforms. We’ve started with Office 365 services, and intend to add more services over time.

At TechEd, we announced a preview release of a new set of client libraries for Office 365, for .NET and JavaScript. You can read the announcement for the new Office 365 client libraries on the Office Developer Blog. The .NET Client libraries support WPF, Windows Forms, Windows Store, Xamarin.iOS, Xamarin.Android and ASP.NET apps and Portable Class Libraries, and are delivered via NuGet.

We have also provided an integrated experience for adding these libraries to your apps within Visual Studio. Services require app registration, permission selection and a platform-specific user authentication experience. You also need to add the right client libraries to your app. The Visual Studio experience takes care of all of that for you, as part of the Connected Services Manager, displayed below.

You can learn how to start using this experience from the Office Developer blog. We are using StackOverflow as the community forum for this project, under the Office365APIs tag. Please tell us what you think about the client libraries and the new Visual Studio integration. Do note that these libraries, and the Office services they are targeting, are in Preview and don’t yet support production apps.

Summary

On the .NET team, we’re excited to be sharing the Next Generation of .NET. As you can see from this post and the one we published at Build, we are lining up a significant set of technologies, features and scenarios that will be part of .NET vNext, our next major release of the .NET Framework. In this post, we focused on ASP.NET vNext, our next generation Web and services platform.

For .NET vNext, we’ve been talking about major features and asking for feedback before we even announced the larger release. We’ve been actively engaging with experts and enthusiasts in our preview and pre-release programs to validate our ideas and product directions. It’s turned out to be a great approach. The feedback has been incredible. Thanks to everyone that has participated in our CTPs, developer previews, pre-releases and any other program we ran to collect feedback. We’ve also received great feedback in blog comments. It’s all been very helpful. Do expect multiple additional preview releases over the coming months, particularly for ASP.NET vNext. It’s going to be a fun time.

You can see how these technology investments come together into a single .NET Framework release, in the following slide that we showed at TechEd. Open Source is also an important part of our plans, as you can see with our ASP.NET vNext contribution plans with the .NET Foundation. The future looks very bright for .NET.

How you can run your codes online without installing any IDE/ software

[http://www.tutorialspoint.com/online_dev_tools.htm]

Here are some great websites for compiling and executing your code online

While some compilers are easy to install and use, some of them are expensive to memory and RAM. The solution is to compile the code online, run it and download the executable to your computer by using an online IDE. A list of such websites is following:

IDEOne

http://ideone.com/

Ideone is an online compiler and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages. These include C, C++, C#, Objective C, Java, Pascal, Perl, PHP, Ada, COBOL, FORTRAN, Bash(Bash is a shell used in Linux) etc.’
IDE

CodePad

http://codepad.org/

codepad.org is an online compiler/interpreter, and a simple collaboration tool. It’s a pastebin that executes code for you. You paste your code, and codepad runs it and gives you a short URL you can use to share it. Paste the URL into chat or email to get help or to show someone how to do something. Or just try things out when you don’t have an interpreter handy. It works well on many phones.
The languages supported include C, C++, Perl, PHP, Python etc.
IDE

Compile-Online

It is another great online IDE with support for almost every well known programming languageIDE.

JDoodle

https://www.jdoodle.com/

“Online compiler and Editor for Java, C, C++, Perl, PHP, Python and More…”

IDE

With these sites you will just need an internet connection to run your code and you can avoid all issues which are invoked after installation of compiler or interpreter software.

If a website which deserves a place in this list and has been missed by us, let us know in the comments.

How to request a random row in SQL?

SELECT TOP 10 [NAME]
,[ROLL_NO]
,[PASS_YEAR]
,[BOARD_NAME]
,[SSC_ROLLNO]
,[SSC_PASSYR]
,[SSC_BOARD]
FROM [Admission2015].[dbo].[DHKH2015] ORDER BY NEWID()

Select a random row with MySQL:

SELECT column FROM table
ORDER BY RAND()
LIMIT 1

Select a random row with PostgreSQL:

SELECT column FROM table
ORDER BY RANDOM()
LIMIT 1

Select a random row with Microsoft SQL Server:

SELECT TOP 1 column FROM table
ORDER BY NEWID()

Select a random row with IBM DB2

SELECT column, RAND() as IDX 
FROM table 
ORDER BY IDX FETCH FIRST 1 ROWS ONLY

Select a random record with Oracle:

SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1

Basic Authentication in ASP.NET Web API

Original Post: http://www.asp.net/web-api/overview/security/basic-authentication

Basic authentication is defined in RFC 2617, HTTP Authentication: Basic and Digest Access Authentication.

Advantages Disadvantages
  • Internet standard.
  • Supported by all major browsers.
  • Relatively simple protocol.
  • User credentials are sent in the request.
  • Credentials are sent as plaintext.
  • Credentials are sent with every request.
  • No way to log out, except by ending the browser session.
  • Vulnerable to cross-site request forgery (CSRF); requires anti-CSRF measures.

Basic authentication works as follows:

  1. If a request requires authentication, the server returns 401 (Unauthorized). The response includes a WWW-Authenticate header, indicating the server supports Basic authentication.
  2. The client sends another request, with the client credentials in the Authorization header. The credentials are formatted as the string “name:password”, base64-encoded. The credentials are not encrypted.

Basic authentication is performed within the context of a “realm.” The server includes the name of the realm in the WWW-Authenticate header. The user’s credentials are valid within that realm. The exact scope of a realm is defined by the server. For example, you might define several realms in order to partition resources.

Because the credentials are sent unencrypted, Basic authentication is only secure over HTTPS. See Working with SSL in Web API.

Basic authentication is also vulnerable to CSRF attacks. After the user enters credentials, the browser automatically sends them on subsequent requests to the same domain, for the duration of the session. This includes AJAX requests. See Preventing Cross-Site Request Forgery (CSRF) Attacks.

Code to Development Basic Authentication with C# ASP.net

string authorization = Request.Headers["Authorization"];
string userInfo;
string username = "";
string password = "";
if (authorization != null)
{
     byte[] tempConverted = Convert.FromBase64String(authorization.Replace("Basic ", "").Trim());
     userInfo = System.Text.Encoding.UTF8.GetString(tempConverted);
     string[] usernamePassword = userInfo.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
     username = usernamePassword[0];
     password = usernamePassword[1];
}

if (username == "yourusername" && password == "yourpassword")
{
}
else
{
     Response.AddHeader("WWW-Authenticate", "Basic realm=\"Test\"");
     Response.StatusCode = 401;
     Response.End();
}

HTTP Web Request for Client

string url = @”http://sample?param1=sdf&param2=23″;
//Uri uri = new Uri(url);
String ResponseMsg = “”;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers[“Authorization”] = “Basic [base64 encoded string]”; // tobase64(userid:password)
request.Host = “101.110.200.12”;
request.PreAuthenticate = true;

HttpWebResponse objResponse = (HttpWebResponse)request.GetResponse();

using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
ResponseMsg = sr.ReadToEnd();
sr.Close();
}
}
catch (Exception ex) { ResponseMsg = “”; }

Basic Authentication with IIS

IIS supports Basic authentication, but there is a caveat: The user is authenticated against their Windows credentials. That means the user must have an account on the server’s domain. For a public-facing web site, you typically want to authenticate against an ASP.NET membership provider.

To enable Basic authentication using IIS, set the authentication mode to “Windows” in the Web.config of your ASP.NET project:

<system.web>
    <authentication mode="Windows" />
</system.web>

In this mode, IIS uses Windows credentials to authenticate. In addition, you must enable Basic authentication in IIS. In IIS Manager, go to Features View, select Authentication, and enable Basic authentication.

In your Web API project, add the [Authorize] attribute for any controller actions that need authentication.

A client authenticates itself by setting the Authorization header in the request. Browser clients perform this step automatically. Nonbrowser clients will need to set the header.

Basic Authentication with Custom Membership

As mentioned, the Basic Authentication built into IIS uses Windows credentials. That means you need to create accounts for your users on the hosting server. But for an internet application, user accounts are typically stored in an external database.

The following code how an HTTP module that performs Basic Authentication. You can easily plug in an ASP.NET membership provider by replacing the CheckPassword method, which is a dummy method in this example.

In Web API 2, you should consider writing an authentication filter or OWIN middleware, instead of an HTTP module.

namespace WebHostBasicAuth.Modules
{
    public class BasicAuthHttpModule : IHttpModule
    {
        private const string Realm = "My Realm";

        public void Init(HttpApplication context)
        {
            // Register event handlers
            context.AuthenticateRequest += OnApplicationAuthenticateRequest;
            context.EndRequest += OnApplicationEndRequest;
        }

        private static void SetPrincipal(IPrincipal principal)
        {
            Thread.CurrentPrincipal = principal;
            if (HttpContext.Current != null)
            {
                HttpContext.Current.User = principal;
            }
        }

        // TODO: Here is where you would validate the username and password.
        private static bool CheckPassword(string username, string password)
        {
            return username == "user" && password == "password";
        }

        private static void AuthenticateUser(string credentials)
        {
            try
            {
                var encoding = Encoding.GetEncoding("iso-8859-1");
                credentials = encoding.GetString(Convert.FromBase64String(credentials));

                int separator = credentials.IndexOf(':');
                string name = credentials.Substring(0, separator);
                string password = credentials.Substring(separator + 1);

                if (CheckPassword(name, password))
                {
                    var identity = new GenericIdentity(name);
                    SetPrincipal(new GenericPrincipal(identity, null));
                }
                else
                {
                    // Invalid username or password.
                    HttpContext.Current.Response.StatusCode = 401;
                }
            }
            catch (FormatException)
            {
                // Credentials were not formatted correctly.
                HttpContext.Current.Response.StatusCode = 401;
            }
        }

        private static void OnApplicationAuthenticateRequest(object sender, EventArgs e)
        {
            var request = HttpContext.Current.Request;
            var authHeader = request.Headers["Authorization"];
            if (authHeader != null)
            {
                var authHeaderVal = AuthenticationHeaderValue.Parse(authHeader);

                // RFC 2617 sec 1.2, "scheme" name is case-insensitive
                if (authHeaderVal.Scheme.Equals("basic",
                        StringComparison.OrdinalIgnoreCase) &&
                    authHeaderVal.Parameter != null)
                {
                    AuthenticateUser(authHeaderVal.Parameter);
                }
            }
        }

        // If the request was unauthorized, add the WWW-Authenticate header 
        // to the response.
        private static void OnApplicationEndRequest(object sender, EventArgs e)
        {
            var response = HttpContext.Current.Response;
            if (response.StatusCode == 401)
            {
                response.Headers.Add("WWW-Authenticate",
                    string.Format("Basic realm=\"{0}\"", Realm));
            }
        }

        public void Dispose() 
        {
        }
    }
}

To enable the HTTP module, add the following to your web.config file in the system.webServer section:

  <system.webServer>
    <modules>
      <add name="BasicAuthHttpModule" 
        type="WebHostBasicAuth.Modules.BasicAuthHttpModule, YourAssemblyName"/>
    </modules>

Replace “YourAssemblyName” with the name of the assembly (not including the “dll” extension).

You should disable other authentication schemes, such as Forms or Windows auth.

ASP.NET C# jQuery Modal Preview of a Form and Check Validation

A. .aspx Code

<asp:Content ID=”HeaderContent” runat=”server” ContentPlaceHolderID=”HeadContent”>
<script type=”text/javascript” src=”Scripts/jquery-2.1.3.min.js”></script>
<script type=”text/javascript” src=”Scripts/jquery.validate.min.js”></script>
<script type=”text/javascript” src=”Scripts/formToWizard.js”></script>
<%–+++++++++++++++++++++++++++++++++ Start Form to wizard making control scripting ++++++++++++++++++++++++++++++++++–%>
<script type=”text/javascript”>
$(document).ready(function () {
$(“#<%=SignupForm.ClientID %>”).formToWizard({ submitButton: ‘SaveAccount’ })
});
</script>
<style type=”text/css”>
#main
{
width: 735px;
margin: 0px auto;
border: solid 1px #b2b3b5;
-moz-border-radius: 10px;
padding: 20px;
background-color: #f6f6f6;
}
/* #header
{
text-align: center;
border-bottom: solid 1px #b2b3b5;
margin: 0 0 20px 0;
}*/
fieldset
{
border: none;
width: 320px;
}
legend
{
font-size: 18px;
margin: 0px;
padding: 10px 0px;
color: #b0232a;
font-weight: bold;
}
label
{
display: block;
margin: 15px 0 5px;
}
/* input[type=text], input[type=password]
{
width: 300px;
padding: 5px;
border: solid 1px #000;
}*/
.prev, .next
{
background-color: #b0232a;
padding: 5px 10px;
color: #fff;
text-decoration: none;
}
.prev:hover, .next:hover
{
background-color: #ccc;
text-decoration: none;
}
.prev
{
float: left;
}
.next
{
float: right;
}
#steps
{
list-style: none;
width: 100%;
overflow: hidden;
margin: 0px;
padding: 0px;
}
#steps li
{
font-size: 24px;
float: left;
padding: 10px;
color: #b0b1b3;
}
#steps li span
{
font-size: 11px;
display: block;
}
#steps li.current
{
color: #000;
}
#makeWizard
{
background-color: #b0232a;
color: #fff;
padding: 5px 10px;
text-decoration: none;
font-size: 18px;
}
#makeWizard:hover
{
background-color: #000;
}
</style>
<%–+++++++++++++++++++++++++++++++++ End Form to wizard making control scripting ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start Form Control CSS ++++++++++++++++++++++++++++++++++–%>
<style type=”text/css”>
.error
{
color: red;
}

.tb10
{
background-image: url(images/form_bg.jpg);
background-repeat: repeat-x;
border: 1px solid #d1c7ac;
width: 230px;
color: #333333;
padding: 3px;
margin-right: 4px;
margin-bottom: 8px;
font-family: tahoma, arial, sans-serif;
}

.form-control
{
display: block;
width: 90%;
height: 34px;
padding: 0px 5px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-o-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-ms-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
-moz-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
-ms-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
.form-control:focus
{
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
-o-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
-ms-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
}
.form-control::-moz-placeholder
{
color: #999;
opacity: 1;
}
.form-control:-ms-input-placeholder
{
color: #999;
}
.form-control::-webkit-input-placeholder
{
color: #999;
}
.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control
{
cursor: not-allowed;
background-color: #eee;
opacity: 1;
}
textarea.form-control
{
height: auto;
}

.btn
{
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus
{
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.btn:hover, .btn:focus, .btn.focus
{
color: #333;
text-decoration: none;
}
.btn:active, .btn.active
{
background-image: none;
outline: 0;
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
-moz-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
-o-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
-ms-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
}

.btn-default
{
color: #333;
background-color: #fff;
border-color: #ccc;
}
.btn-default:hover, .btn-default:focus, .btn-default.focus, .btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default
{
color: #333;
background-color: #e6e6e6; /* border-color: #adadad; */
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
-o-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
-ms-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
}
.btn-default:active, .btn-default.active, .open > .dropdown-toggle.btn-default
{
background-image: none;
}
</style>
<%–+++++++++++++++++++++++++++++++++ End Form Control CSS ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start Number only and Submit Confirmation Script ++++++++++++++++++++++++++++++++++–%>
<script type=”text/javascript”>
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 45 || charCode > 57))
return false;

return true;
};

function executeOnSubmit() {
var res = confirm(“Are you sure to perform the action?”);
if (res)
return true;
else
return false;
};
</script>
<%–+++++++++++++++++++++++++++++++++ End Number only and Submit Confirmation Script ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start Roll Number and Board value is provided? ++++++++++++++++++++++++++++++++++–%>
<script type=”text/javascript”>
function CheckSubmit() {
var IsError = 0;
var Msg = “”;

if ($(‘#<%=txtSSCRollNo.ClientID %>’).val() == “”) {
IsError = 1;
Msg += “Please input SSC Roll Number!<br/>”;
}
if ($(‘#<%=drpSSCBoard.ClientID %>’).val() == “Select”) {
IsError = 1;
Msg += “Please Select SSC Board!<br/>”;
}
if ($(‘#<%=txtHSCRollNo.ClientID %>’).val() == “”) {
IsError = 1;
Msg += “Please input HSC Roll Number!<br/>”;
}
if ($(‘#<%=drpHSCBoard.ClientID %>’).val() == “Select”) {
IsError = 1;
Msg += “Please Select HSC Board!<br/>”;
}

if (IsError == 1) {
$(‘#<%=divMsg.ClientID%>’).html(Msg);
return false;
}
else {
return true;
}
}
</script>
<%–+++++++++++++++++++++++++++++++++ End Roll Number and Board value is provided? ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start Image preview during uploading a image ++++++++++++++++++++++++++++++++++–%>
<script type=”text/javascript”>
$(function () {
$(“#<%=CandidatePicture.ClientID %>”).on(“change”, function () {
var files = !!this.files ? this.files : [];
if (!files.length || !window.FileReader) return; // no file selected, or no FileReader support

if (/^image/.test(files[0].type)) { // only image file
var reader = new FileReader(); // instance of the FileReader
reader.readAsDataURL(files[0]); // read the local file

reader.onloadend = function () { // set image data as background of div
$(“#imagePreview”).css(“background-image”, “url(” + this.result + “)”);
$(“div#dialog-image”).css(“background-image”, “url(” + this.result + “)”);
}
}
});
});
$(function () {
$(“#<%=CandidateSignature.ClientID %>”).on(“change”, function () {
var files = !!this.files ? this.files : [];
if (!files.length || !window.FileReader) return; // no file selected, or no FileReader support

if (/^image/.test(files[0].type)) { // only image file
var reader = new FileReader(); // instance of the FileReader
reader.readAsDataURL(files[0]); // read the local file

reader.onloadend = function () { // set image data as background of div
$(“#signaturePreview”).css(“background-image”, “url(” + this.result + “)”);
$(“div#dialog-signature”).css(“background-image”, “url(” + this.result + “)”);
}
}
});
});
</script>
<style type=”text/css”>
#imagePreview
{
width: 180px;
height: 180px;
background-position: center center;
background-size: cover;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .3);
display: inline-block;
}
#signaturePreview
{
width: 180px;
height: 48px;
background-position: center center;
background-size: cover;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .3);
display: inline-block;
}

#dialog-image
{
width: 180px;
height: 180px;
background-position: center center;
background-size: cover;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .3);
display: inline-block;
}

#dialog-signature
{
width: 180px;
height: 48px;
background-position: center center;
background-size: cover;
-webkit-box-shadow: 0 0 1px 1px rgba(0, 0, 0, .3);
display: inline-block;
}
</style>
<%–+++++++++++++++++++++++++++++++++ End Image preview during uploading a image ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start jQuery UI Modal Preview ++++++++++++++++++++++++++++++++++–%>
<link type=”text/css” href=”~/jQueryui/jquery-ui.css” />
<script type=”text/javascript” src=”jQueryui/jquery-ui.js”></script>
<script type=”text/javascript”>

</script>
<script type=”text/javascript”>
$(function () {
$(“#<%=WiztxtDOB.ClientID %>”).datepicker({
dateFormat: “yy-mm-dd”,
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: “-30:-15″
});
});
</script>
<script type=”text/javascript”>
$(document).ready(function () {
$(‘#<%=CkbCondition.ClientID %>’).click(function () {
if ($(this).is(‘:checked’)) {
$(‘#<%=btnPreview.ClientID %>’).removeAttr(‘disabled’);
$(‘#<%=btnCancel.ClientID %>’).removeAttr(‘disabled’);
} else {
$(‘#<%=btnPreview.ClientID %>’).attr(‘disabled’, ‘disabled’);
$(‘#<%=btnCancel.ClientID %>’).attr(‘disabled’, ‘disabled’);
}
});
});
</script>
<%–+++++++++++++++++++++++++++++++++ End jQuery UI Modal Preview ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start SUM of four subjects’ GPA ++++++++++++++++++++++++++++++++++–%>
<script type=”text/javascript”>
$(document).ready(function () {

$(“#<%=WiztxtHSCPhysics.ClientID %>”).keyup(function () {
var phy = $(“#<%=WiztxtHSCPhysics.ClientID %>”).val();
var chem = $(“#<%=WiztxtHSCChemistry.ClientID %>”).val();
var math = $(“#<%=WiztxtHSCMathematics.ClientID %>”).val();
var eng = $(“#<%=WiztxtHSCEnglish.ClientID %>”).val();
var sum = parseFloat(phy) + parseFloat(chem) + parseFloat(math) + parseFloat(eng);
$(“#<%=WiztxtHSCTotal.ClientID %>”).val(sum);
});

$(“#<%=WiztxtHSCChemistry.ClientID %>”).keyup(function () {
var phy = $(“#<%=WiztxtHSCPhysics.ClientID %>”).val();
var chem = $(“#<%=WiztxtHSCChemistry.ClientID %>”).val();
var math = $(“#<%=WiztxtHSCMathematics.ClientID %>”).val();
var eng = $(“#<%=WiztxtHSCEnglish.ClientID %>”).val();
var sum = parseFloat(phy) + parseFloat(chem) + parseFloat(math) + parseFloat(eng);
$(“#<%=WiztxtHSCTotal.ClientID %>”).val(sum);
});

$(“#<%=WiztxtHSCMathematics.ClientID %>”).keyup(function () {
var phy = $(“#<%=WiztxtHSCPhysics.ClientID %>”).val();
var chem = $(“#<%=WiztxtHSCChemistry.ClientID %>”).val();
var math = $(“#<%=WiztxtHSCMathematics.ClientID %>”).val();
var eng = $(“#<%=WiztxtHSCEnglish.ClientID %>”).val();
var sum = parseFloat(phy) + parseFloat(chem) + parseFloat(math) + parseFloat(eng);
$(“#<%=WiztxtHSCTotal.ClientID %>”).val(sum);
});

$(“#<%=WiztxtHSCEnglish.ClientID %>”).keyup(function () {
var phy = $(“#<%=WiztxtHSCPhysics.ClientID %>”).val();
var chem = $(“#<%=WiztxtHSCChemistry.ClientID %>”).val();
var math = $(“#<%=WiztxtHSCMathematics.ClientID %>”).val();
var eng = $(“#<%=WiztxtHSCEnglish.ClientID %>”).val();
var sum = parseFloat(phy) + parseFloat(chem) + parseFloat(math) + parseFloat(eng);
$(“#<%=WiztxtHSCTotal.ClientID %>”).val(sum);
});

});
</script>
<%–+++++++++++++++++++++++++++++++++ End SUM of four subjects’ GPA ++++++++++++++++++++++++++++++++++–%>
<%–+++++++++++++++++++++++++++++++++ Start Modal Preview with Image ++++++++++++++++++++++++++++++++++–%>
<script type=”text/javascript”>
       jQuery(document).ready(function() {
            $(‘#dialog’).dialog({
                autoOpen: false,               
                width: 800,                
                resizable: false,
                modal:true,
                buttons: {
                    “Submit”: function()
                    {
                        $(this).dialog(“close”);
                        <%= Page.ClientScript.GetPostBackEventReference(this.btnPreview, string.Empty) %>;
                    },
                    “Cancel”: function()
                    {
                        $(this).dialog(“close”);
                    }
                }
            });

             $(‘#<%=btnPreview.ClientID%>’).click(function (e) {

             if (Page_ClientValidate())
             {
                $(“p#dialog-name”).html($(“#<%=WiztxtName.ClientID%>”).val());   
                $(“p#fname”).html($(“#<%=WiztxtFatherName.ClientID%>”).val());  
                $(“p#mname”).html($(“#<%=WiztxtMotherName.ClientID%>”).val());
                
                $(“p#dob”).html($(“#<%=WiztxtDOB.ClientID%>”).val());
                $(“p#sex”).html($(“#<%=WizddlSex.ClientID%>”).val());
                $(“p#religion”).html($(“#<%=WizddlReligion.ClientID%>”).val());
                $(“p#tribal”).html($(“#<%=WizddlTribal.ClientID%>”).val());
                
                $(“p#tbDistrict”).html($(“#<%=WiztxtTribalDistrict.ClientID%>”).val());
                $(“p#nationality”).html($(“#<%=WiztxtNationality.ClientID%>”).val());
                $(“p#phone”).html($(“#<%=WiztxtPhone.ClientID%>”).val());
                $(“p#mobile”).html($(“#<%=WiztxtMobile.ClientID%>”).val());
                
                $(“p#email”).html($(“#<%=WiztxtEmail.ClientID%>”).val());
                $(“p#birthPlace”).html($(“#<%=WiztxtBirthPlace.ClientID%>”).val());

                $(“p#guardian”).html($(“#<%=WiztxtGuardian.ClientID%>”).val());
                $(“p#relation”).html($(“#<%=WizddlRelation.ClientID%>”).val());
                $(“p#garAddress”).html($(“#<%=WiztxtGardianAddress.ClientID%>”).val());
                $(“p#garEmail”).html($(“#<%=WiztxtGardianEmail.ClientID%>”).val());  
                
                $(“p#garMobile”).html($(“#<%=WiztxtGardianMobile.ClientID%>”).val());
                $(“p#garPhone”).html($(“#<%=WiztxtGardianPhone.ClientID%>”).val());  
                
                $(“p#presentDivision”).html($(“#<%=WizddlPreDivision.ClientID%>”).children(“option:selected”).text());  
                $(“p#presentDistrict”).html($(“#<%=WizddlPreDistrict.ClientID%>”).children(“option:selected”).text());  
                $(“p#presentThana”).html($(“#<%=WizddlPreThana.ClientID%>”).children(“option:selected”).text());  
                $(“p#presentAddresss”).html($(“#<%=WiztxtPreAddresss.ClientID%>”).val());  
                
                $(“p#permanentDivision”).html($(“#<%=WizddlPerDivision.ClientID%>”).children(“option:selected”).text());  
                $(“p#permanentDistrict”).html($(“#<%=WizddlPerDistrict.ClientID%>”).children(“option:selected”).text());  
                $(“p#permanentThana”).html($(“#<%=WizddlPerThana.ClientID%>”).children(“option:selected”).text());  
                $(“p#permanentAddresss”).html($(“#<%=WiztxtPerAddresss.ClientID%>”).val());  
                
                $(“p#sscyear”).html($(“#<%=WiztxtSSCYear.ClientID%>”).val());  
                $(“p#sscroll”).html($(“#<%=WiztxtSSCRoll.ClientID%>”).val());  
                $(“p#sscboard”).html($(“#<%=WiztxtSSCBoardName.ClientID%>”).val());  
                $(“p#sscinstitute”).html($(“#<%=WiztxtSSCInstitute.ClientID%>”).val());  
                
                $(“p#hscyear”).html($(“#<%=WiztxtHSCYear.ClientID%>”).val());  
                $(“p#hscroll”).html($(“#<%=WiztxtHSCRoll.ClientID%>”).val());  
                $(“p#hscboard”).html($(“#<%=WiztxtHSCBoardName.ClientID%>”).val());  
                $(“p#hscinstitute”).html($(“#<%=WiztxtHSCInstitute.ClientID%>”).val());   
                
                $(“p#sscscale”).html($(“#<%=WiztxtSSCScale.ClientID%>”).val());  
                $(“p#sscgpa”).html($(“#<%=WiztxtSSCCGPA.ClientID%>”).val());  
                $(“p#hscscale”).html($(“#<%=WiztxtHSCScale.ClientID%>”).val());  
                $(“p#hscgpa”).html($(“#<%=WiztxtHSCCGPA.ClientID%>”).val());  
                
                $(“p#gpaphysics”).html($(“#<%=WiztxtHSCPhysics.ClientID%>”).val());  
                $(“p#gpachemistry”).html($(“#<%=WiztxtHSCChemistry.ClientID%>”).val());  
                $(“p#gpamathematics”).html($(“#<%=WiztxtHSCMathematics.ClientID%>”).val());  
                $(“p#gpaenglish”).html($(“#<%=WiztxtHSCEnglish.ClientID%>”).val());   
                
                $(“p#gpatotal”).html($(“#<%=WiztxtHSCTotal.ClientID%>”).val());   
                $(“p#mediumInstructions”).html($(“#<%=ddlMediumOfInstruction.ClientID%>”).children(“option:selected”).text());               

                $(‘#dialog’).dialog(‘open’);
                return false;
            }
            else
            {
                 $(“#validation_dialog”).dialog({
                            title: “Validation Error!”,
                            modal: true,
                            resizable: false,
                            buttons: {
                                Close: function () {
                                    $(this).dialog(‘close’);
                                }
                            }
                        });
            }
            });
         });
    </script>
<%–+++++++++++++++++++++++++++++++++ End Modal Preview with Image ++++++++++++++++++++++++++++++++++–%>
</asp:Content>
<asp:Content ID=”BodyContent” runat=”server” ContentPlaceHolderID=”MainContent”>
<div align=”center” style=”font-family: Verdana; font-size: 14px;”>
<br />
<h2>
Welcome to Undergraduate Admission System!
</h2>
<div id=”main”>
<form id=”SignupForm” action=”” runat=”server”>
<script type=”text/javascript”>
function WebForm_OnSubmit() {
if (typeof (ValidatorOnSubmit) == “function” && ValidatorOnSubmit() == false) {
$(“#validation_dialog”).dialog({
title: “Validation Error!”,
modal: true,
resizable: false,
buttons: {
Close: function () {
$(this).dialog(‘close’);
}
}
});
return false;
}
return true;
}
</script>
<asp:ScriptManager EnablePartialRendering=”true” ID=”ScriptManager1″ runat=”server” />
<asp:Label ID=”lblMsg” runat=”server” Font-Bold=”True” Font-Italic=”True” ForeColor=”Red”></asp:Label>
<div align=”center” id=”divSearch” runat=”server”>
<div id=”divMsg” runat=”server” style=”font-family: Verdana; color: Red;” align=”center”>
</div>
<table width=”90%”>
<tr>
<td>
S.S.C Roll
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”txtSSCRollNo” Width=”100px” runat=”server” class=”form-control”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</td>
<td>
Passing Year
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”ddlSSCYear” Width=”100px” class=”form-control” runat=”server”>
<%–<asp:ListItem Text=”2013″ Value=”2013″></asp:ListItem>
<asp:ListItem Text=”2012″ Value=”2012″></asp:ListItem>–%>
</asp:DropDownList>
</td>
<td>
S.S.C Board
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”drpSSCBoard” Width=”150px” class=”form-control” runat=”server”>
<asp:ListItem Text=”Select” Value=”Select”></asp:ListItem>
<asp:ListItem Text=”Barisal” Value=”Barisal”></asp:ListItem>
<asp:ListItem Text=”Chittagong” Value=”Chittagong”></asp:ListItem>
<asp:ListItem Text=”Comilla” Value=”Comilla”></asp:ListItem>
<asp:ListItem Text=”Dhaka” Value=”Dhaka”></asp:ListItem>
<asp:ListItem Text=”Dinajpur” Value=”Dinajpur”></asp:ListItem>
<asp:ListItem Text=”Jessore” Value=”Jessore”></asp:ListItem>
<asp:ListItem Text=”Rajshahi” Value=”Rajshahi”></asp:ListItem>
<asp:ListItem Text=”Sylhet” Value=”Sylhet”></asp:ListItem>
<asp:ListItem Text=”Madrasah” Value=”Madrasah”></asp:ListItem>
<asp:ListItem Text=”Technical” Value=”Technical”></asp:ListItem>
<asp:ListItem Text=”Other” Value=”Other”></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
H.S.C Roll
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”txtHSCRollNo” Width=”100px” runat=”server” class=”form-control”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</td>
<td>
Passing Year
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”ddlHSCYear” Width=”100px” class=”form-control” runat=”server”>
<%–<asp:ListItem Text=”2015″ Value=”2015″></asp:ListItem>–%>
</asp:DropDownList>
</td>
<td>
H.S.C Board
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”drpHSCBoard” Width=”150px” class=”form-control” runat=”server”>
<asp:ListItem Text=”Select” Value=”Select”></asp:ListItem>
<asp:ListItem Text=”Barisal” Value=”Barisal”></asp:ListItem>
<asp:ListItem Text=”Chittagong” Value=”Chittagong”></asp:ListItem>
<asp:ListItem Text=”Comilla” Value=”Comilla”></asp:ListItem>
<asp:ListItem Text=”Dhaka” Value=”Dhaka”></asp:ListItem>
<asp:ListItem Text=”Dinajpur” Value=”Dinajpur”></asp:ListItem>
<asp:ListItem Text=”Jessore” Value=”Jessore”></asp:ListItem>
<asp:ListItem Text=”Rajshahi” Value=”Rajshahi”></asp:ListItem>
<asp:ListItem Text=”Sylhet” Value=”Sylhet”></asp:ListItem>
<asp:ListItem Text=”Madrasah” Value=”Madrasah”></asp:ListItem>
<asp:ListItem Text=”Technical” Value=”Technical”></asp:ListItem>
<asp:ListItem Text=”Other” Value=”Other”></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan=”9″ align=”right”>
<div align=”right”>
<asp:Button ID=”btnSubmit” runat=”server” Text=”Submit” class=”btn btn-default” OnClientClick=”return CheckSubmit();”
OnClick=”btnSubmit_Click” />
</div>
</td>
</tr>
</table>
<div style=”margin-top: 10px; margin-left: 30px; margin-right: 30px; margin-bottom: 20px;
text-align: left; font-family: Verdana; font-size: 14px; font-style: italic;
color: Purple;” align=”left”>
<strong>Instruction:</strong> To best view and performance use latest Mozilla Firefox,
Google Chrome, Safari and Opera web Browser.
</div>
</div>
<div id=”divWizard” runat=”server” align=”center”>
<div align=”center”>
<fieldset>
<legend>Personal</legend>
<table width=”720px”>
<tr>
<td valign=”middle”>
Name *
</td>
<td valign=”middle”>
:
</td>
<td>
<asp:TextBox ID=”WiztxtName” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
<td>
Father’s Name *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtFatherName” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”req1″ runat=”Server” ControlToValidate=”WiztxtName”
ErrorMessage=”Name is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<%–Display=”None”–%>
</td>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”Server” ControlToValidate=”WiztxtFatherName”
ErrorMessage=”Father Name is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
</tr>
<tr>
<td>
Mother’s Name *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtMotherName” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
<td>
Date of Birth *<br />
[yyyy-MM-dd]
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtDOB” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”Server” ControlToValidate=”WiztxtMotherName”
ErrorMessage=”Mother Name is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator3″ runat=”Server” ControlToValidate=”WiztxtDOB”
ErrorMessage=”DOB is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
</tr>
<tr>
<td>
Sex *
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlSex” runat=”server” class=”form-control” Width=”212px”>
<asp:ListItem Text=”Select” Value=”Select”></asp:ListItem>
<asp:ListItem Text=”MALE” Value=”MALE”></asp:ListItem>
<asp:ListItem Text=”FEMALE” Value=”FEMALE”></asp:ListItem>
<asp:ListItem Text=”Others” Value=”Others”></asp:ListItem>
</asp:DropDownList>
</td>
<td>
Religion view
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlReligion” runat=”server” class=”form-control” Width=”212px”>
<asp:ListItem Text=”Select” Value=”Select”></asp:ListItem>
<asp:ListItem Text=”Islam” Value=”Islam”></asp:ListItem>
<asp:ListItem Text=”Hinduism” Value=”Hinduism”></asp:ListItem>
<asp:ListItem Text=”Buddhism” Value=”Buddhism”></asp:ListItem>
<asp:ListItem Text=”Christianity” Value=”Christianity”></asp:ListItem>
<asp:ListItem Text=”Secularism” Value=”Secularism”></asp:ListItem>
<asp:ListItem Text=”Others” Value=”Others”></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Is Tribal? *
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlTribal” runat=”server” class=”form-control” Width=”212px”>
<asp:ListItem Text=”No” Value=”No”></asp:ListItem>
<asp:ListItem Text=”Chakma” Value=”Chakma”></asp:ListItem>
<asp:ListItem Text=”Marma” Value=”Marma”></asp:ListItem>
<asp:ListItem Text=”Tippera” Value=”Tippera”></asp:ListItem>
<asp:ListItem Text=”Tripura” Value=”Tripura”></asp:ListItem>
<asp:ListItem Text=”Khasia” Value=”Khasia”></asp:ListItem>
<asp:ListItem Text=”Rakhain” Value=”Rakhain”></asp:ListItem>
<asp:ListItem Text=”Manipuri” Value=”Manipuri”></asp:ListItem>
<asp:ListItem Text=”Mro” Value=”Mro”></asp:ListItem>
<asp:ListItem Text=”Mru” Value=”Mru”></asp:ListItem>
<asp:ListItem Text=”Tanchangya” Value=”Tanchangya”></asp:ListItem>
<asp:ListItem Text=”Tanchyanga” Value=”Tanchyanga”></asp:ListItem>
<asp:ListItem Text=”Chak” Value=”Chak”></asp:ListItem>
<asp:ListItem Text=”Kuki” Value=”Kuki”></asp:ListItem>
<asp:ListItem Text=”Lushai” Value=”Lushai”></asp:ListItem>
<asp:ListItem Text=”Khyang” Value=”Khyang”></asp:ListItem>
<asp:ListItem Text=”Pankho” Value=”Pankho”></asp:ListItem>
<asp:ListItem Text=”Bangoji” Value=”Bangoji”></asp:ListItem>
<asp:ListItem Text=”Murong” Value=”Murong”></asp:ListItem>
<asp:ListItem Text=”Mandi” Value=”Mandi”></asp:ListItem>
<asp:ListItem Text=”Hajong” Value=”Hajong”></asp:ListItem>
<asp:ListItem Text=”Santal” Value=”Santal”></asp:ListItem>
<asp:ListItem Text=”Bawm” Value=”Bawm”></asp:ListItem>
<asp:ListItem Text=”Khiang” Value=”Khiang”></asp:ListItem>
<asp:ListItem Text=”Khumi” Value=”Khumi”></asp:ListItem>
<asp:ListItem Text=”Others” Value=”Others”></asp:ListItem>
</asp:DropDownList>
</td>
<td>
Tribal District
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtTribalDistrict” runat=”server” class=”form-control” Width=”200px”
Text=”N/A”></asp:TextBox>
</td>
</tr>
<tr>
<td>
Nationality *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtNationality” Text=”Bangladeshi” runat=”server” class=”form-control”
Width=”200px”></asp:TextBox>
</td>
<td>
Phone
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtPhone” runat=”server” class=”form-control” Width=”200px” onkeypress=”return isNumberKey(event);”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator4″ runat=”Server” ControlToValidate=”WiztxtNationality”
ErrorMessage=”Nationality is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
<td colspan=”3″>
</td>
</tr>
<tr>
<td>
Mobile *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtMobile” runat=”server” class=”form-control” Width=”200px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</td>
<td>
Email *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtEmail” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator5″ runat=”Server” ControlToValidate=”WiztxtMobile”
ErrorMessage=”Mobile Number is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
<td colspan=”3″>
<asp:RegularExpressionValidator ID=”regEmail” ControlToValidate=”WiztxtEmail” Text=”(Invalid email)”
ValidationExpression=”\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*” runat=”server”
ValidationGroup=”validation” ForeColor=”Red” />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator6″ runat=”Server” ControlToValidate=”WiztxtEmail”
ErrorMessage=”Email is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
</tr>
<tr>
<td>
Birth Place
</td>
<td>
:
</td>
<td colspan=”4″>
<asp:TextBox ID=”WiztxtBirthPlace” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
</tr>
</table>
<br />
</fieldset>
<fieldset>
<legend>Guardian</legend>
<table width=”700px”>
<tr>
<td>
Guardian Name *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtGuardian” runat=”server” class=”form-control” Width=”200px”></asp:TextBox>
</td>
<td>
Relation *
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlRelation” runat=”server” class=”form-control” Width=”212px”>
<asp:ListItem Text=”Select” Value=”Select”></asp:ListItem>
<asp:ListItem Text=”Father-son” Value=”Father-son”></asp:ListItem>
<asp:ListItem Text=”Father-daughter” Value=”Father-daughter”></asp:ListItem>
<asp:ListItem Text=”Mother-son” Value=”Mother-son”></asp:ListItem>
<asp:ListItem Text=”Mother-daughter” Value=”Mother-daughter”></asp:ListItem>
<asp:ListItem Text=”Brother” Value=”Brother”></asp:ListItem>
<asp:ListItem Text=”Sister” Value=”Sister”></asp:ListItem>
<asp:ListItem Text=”Grand Father” Value=”Grand Father”></asp:ListItem>
<asp:ListItem Text=”Grand Mother” Value=”Grand Mother”></asp:ListItem>
<asp:ListItem Text=”Uncle” Value=”Uncle”></asp:ListItem>
<asp:ListItem Text=”Aunty” Value=”Aunty”></asp:ListItem>
<asp:ListItem Text=”Brother in law” Value=”Brother in law”></asp:ListItem>
<asp:ListItem Text=”Sister in law” Value=”Sister in law”></asp:ListItem>
<asp:ListItem Text=”Husband” Value=”Husband”></asp:ListItem>
<asp:ListItem Text=”Wife” Value=”Wife”></asp:ListItem>
<asp:ListItem Text=”Father in law” Value=”Father in law”></asp:ListItem>
<asp:ListItem Text=”Mother in law” Value=”Mother in law”></asp:ListItem>
<asp:ListItem Text=”Others” Value=”Others”></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator7″ runat=”Server” ControlToValidate=”WiztxtGuardian”
ErrorMessage=”Guardian Name is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
<td colspan=”3″>
</td>
</tr>
<tr>
<td>
Address
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtGardianAddress” runat=”server” class=”form-control” Width=”200px”
Height=”80px” TextMode=”MultiLine”></asp:TextBox>
</td>
<td>
Email
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtGardianEmail” runat=”server” class=”form-control” Width=”200px”
Height=”80px” TextMode=”MultiLine”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”3″>
</td>
<td colspan=”3″>
<asp:RegularExpressionValidator ID=”RegularExpressionValidator1″ ControlToValidate=”WiztxtGardianEmail”
Text=”(Invalid email)” ValidationExpression=”\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”
runat=”server” ValidationGroup=”validation” ForeColor=”Red” />
</td>
</tr>
<tr>
<td>
Mobile *
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtGardianMobile” runat=”server” class=”form-control” Width=”200px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</td>
<td>
Phone
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtGardianPhone” runat=”server” class=”form-control” Width=”200px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”3″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator8″ runat=”Server” ControlToValidate=”WiztxtGardianMobile”
ErrorMessage=”Guardian Mobile is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
<td colspan=”3″>
</td>
</tr>
</table>
<br />
</fieldset>
<fieldset>
<legend>Contact</legend>
<asp:UpdatePanel ID=”UpdatePanel2″ UpdateMode=”Conditional” runat=”server”>
<ContentTemplate>
<table width=”700px”>
<tr>
<td>
Present Division
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlPreDivision” runat=”server” class=”form-control” AutoPostBack=”true”
Width=”212px” OnSelectedIndexChanged=”WizddlPreDivision_SelectedIndexChanged”>
</asp:DropDownList>
</td>
<td>
Present District
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlPreDistrict” runat=”server” class=”form-control” AutoPostBack=”true”
Width=”212px” OnSelectedIndexChanged=”WizddlPreDistrict_SelectedIndexChanged”>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Present Thana
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlPreThana” runat=”server” class=”form-control” Width=”212px”>
</asp:DropDownList>
</td>
<td>
Present Addresss
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtPreAddresss” runat=”server” class=”form-control” Width=”200px”
Height=”80px” TextMode=”MultiLine”></asp:TextBox>
</td>
</tr>
<tr>
<td>
Permanent Division
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlPerDivision” runat=”server” class=”form-control” AutoPostBack=”true”
Width=”212px” OnSelectedIndexChanged=”WizddlPerDivision_SelectedIndexChanged”>
</asp:DropDownList>
</td>
<td>
Permanent District
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlPerDistrict” runat=”server” class=”form-control” AutoPostBack=”true”
Width=”212px” OnSelectedIndexChanged=”WizddlPerDistrict_SelectedIndexChanged”>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Permanent Thana
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”WizddlPerThana” runat=”server” class=”form-control” Width=”212px”>
</asp:DropDownList>
</td>
<td>
Permanent Addresss
</td>
<td>
:
</td>
<td>
<asp:TextBox ID=”WiztxtPerAddresss” runat=”server” class=”form-control” Width=”200px”
Height=”80px” TextMode=”MultiLine”></asp:TextBox>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=”WizddlPreDivision” EventName=”SelectedIndexChanged” />
<asp:AsyncPostBackTrigger ControlID=”WizddlPerDivision” EventName=”SelectedIndexChanged” />
<asp:AsyncPostBackTrigger ControlID=”WizddlPreDistrict” EventName=”SelectedIndexChanged” />
<asp:AsyncPostBackTrigger ControlID=”WizddlPerDistrict” EventName=”SelectedIndexChanged” />
</Triggers>
</asp:UpdatePanel>
<br />
</fieldset>
<fieldset>
<legend>Education</legend>
<table width=”730px” class=”layout display responsive-table”>
<tr>
<th>
<div align=”center”>
Examination
</div>
</th>
<th align=”center”>
<div align=”center”>
Passing Year
</div>
</th>
<th align=”center”>
<div align=”center”>
Roll
</div>
</th>
<th align=”center”>
<div align=”center”>
Reg. No. *
</div>
</th>
<th align=”center”>
<div align=”center”>
Board
</div>
</th>
<th align=”center”>
<div align=”center”>
Institute
</div>
</th>
</tr>
<tr>
<td width=”80px”>
<strong>S.S.C/ Equiv.</strong>
</td>
<td width=”80px”>
<asp:TextBox ID=”WiztxtSSCYear” runat=”server” class=”form-control” Width=”70px”
ReadOnly=”true”></asp:TextBox>
</td>
<td width=”70px”>
<asp:TextBox ID=”WiztxtSSCRoll” runat=”server” class=”form-control” Width=”60px”
ReadOnly=”true”></asp:TextBox>
</td>
<td width=”70px”>
<asp:TextBox ID=”WiztxtSSCRegNo” runat=”server” class=”form-control” Width=”60px”></asp:TextBox>
</td>
<td width=”80px”>
<asp:TextBox ID=”WiztxtSSCBoardName” runat=”server” class=”form-control” Width=”70px”
ReadOnly=”true”></asp:TextBox>
</td>
<td>
<asp:TextBox ID=”WiztxtSSCInstitute” runat=”server” class=”form-control” Width=”180px”></asp:TextBox>
</td>
</tr>
<tr>
<td>
<strong>H.S.C/ Equiv.</strong>
</td>
<td>
<asp:TextBox ID=”WiztxtHSCYear” runat=”server” class=”form-control” Width=”70px”
ReadOnly=”true”></asp:TextBox>
</td>
<td>
<asp:TextBox ID=”WiztxtHSCRoll” runat=”server” class=”form-control” Width=”60px”
ReadOnly=”true”></asp:TextBox>
</td>
<td>
<asp:TextBox ID=”WiztxtHSCRegNo” runat=”server” class=”form-control” Width=”60px”></asp:TextBox>
</td>
<td>
<asp:TextBox ID=”WiztxtHSCBoardName” runat=”server” class=”form-control” Width=”70px”
ReadOnly=”true”></asp:TextBox>
</td>
<td>
<asp:TextBox ID=”WiztxtHSCInstitute” runat=”server” class=”form-control” Width=”180px”></asp:TextBox>
</td>
</tr>
<tr>
<td colspan=”6″>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator9″ runat=”Server” ControlToValidate=”WiztxtSSCRegNo”
ErrorMessage=”S.S.C Reg. No. is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator10″ runat=”Server” ControlToValidate=”WiztxtHSCRegNo”
ErrorMessage=”H.S.C Reg. No. is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
</tr>
</table>
<br />
</fieldset>
<fieldset>
<legend>Result</legend>
<div style=”width: 730px;”>
<table width=”730px” class=”layout display responsive-table”>
<tr>
<th colspan=”2″>
<div align=”center”>
S.S.C
</div>
</th>
<th colspan=”4″>
<div align=”center”>
H.S.C
</div>
</th>
</tr>
<tr>
<td width=”80px”>
<div align=”center”>
Scale *
</div>
</td>
<td width=”80px”>
<div align=”center”>
CGPA *
</div>
</td>
<td width=”80px”>
<div align=”center”>
Scale *
</div>
</td>
<td width=”80px”>
<div align=”center”>
CGPA *
</div>
</td>
<td width=”100px”>
<div align=”center”>
Subject
</div>
</td>
<td>
<div align=”center”>
GPA
</div>
</td>
</tr>
<tr>
<td rowspan=”9″>
<div align=”center”>
<asp:TextBox ID=”WiztxtSSCScale” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
<td rowspan=”9″>
<div align=”center”>
<asp:TextBox ID=”WiztxtSSCCGPA” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
<td rowspan=”9″>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCScale” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
<td rowspan=”9″>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCCGPA” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
<td>
Physics *
</td>
<td>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCPhysics” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
</tr>
<tr>
<td>
Chemistry *
</td>
<td>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCChemistry” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
</tr>
<tr>
<td>
Mathematics *
</td>
<td>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCMathematics” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
</tr>
<tr>
<td>
English *
</td>
<td>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCEnglish” runat=”server” class=”form-control” Width=”50px”
onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
</tr>
<tr>
<td>
Total
</td>
<td>
<div align=”center”>
<asp:TextBox ID=”WiztxtHSCTotal” runat=”server” class=”form-control” Width=”50px”
ReadOnly=”true” onkeypress=”return isNumberKey(event);”></asp:TextBox>
</div>
</td>
</tr>
</table>
<div align=”left”>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator11″ runat=”Server” ControlToValidate=”WiztxtSSCScale”
ErrorMessage=”S.S.C Scale is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator12″ runat=”Server” ControlToValidate=”WiztxtSSCCGPA”
ErrorMessage=”S.S.C GPA is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator13″ runat=”Server” ControlToValidate=”WiztxtHSCScale”
ErrorMessage=”H.S.C Scale is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator14″ runat=”Server” ControlToValidate=”WiztxtHSCCGPA”
ErrorMessage=”H.S.C GPA is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator15″ runat=”Server” ControlToValidate=”WiztxtHSCPhysics”
ErrorMessage=”Physics GPA is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator16″ runat=”Server” ControlToValidate=”WiztxtHSCChemistry”
ErrorMessage=”Chemistry GPA is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator17″ runat=”Server” ControlToValidate=”WiztxtHSCMathematics”
ErrorMessage=”Math GPA is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator18″ runat=”Server” ControlToValidate=”WiztxtHSCEnglish”
ErrorMessage=”English GPA is Required !” ValidationGroup=”validation” ForeColor=”Red” />
<br />
</div>
</div>
<br />
</fieldset>
<fieldset>
<legend>Submission</legend>
<table width=”730px”>
<tr>
<td>
<label for=”CandidatePicture”>
<strong>1.</strong> Picture [Max size: 300 x 300 px & 100 KB] *</label>
<div id=”imagePreview” style=”border: 1px #ccc dashed;” title=”Picture”>
</div>
<br />
<asp:FileUpload ID=”CandidatePicture” runat=”server” class=” img btn btn-default”
Width=”300px” />
</td>
<td>
</td>
<td valign=”top”>
<label for=”CandidateSignature”>
<strong>2.</strong> Signature [Max size: 300 x 80 px & 50 KB] *</label>
<div id=”signaturePreview” style=”border: 1px #ccc dashed;” title=”Picture”>
</div>
<br />
<asp:FileUpload ID=”CandidateSignature” runat=”server” class=” img btn btn-default”
Width=”300px” />
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
<tr>
<td>
<strong>3.</strong> Medium of Instructions/ Question Papers *
</td>
<td>
:
</td>
<td>
<asp:DropDownList ID=”ddlMediumOfInstruction” runat=”server” class=”form-control”
Width=”212px”>
<asp:ListItem Text=”Bangla” Value=”Bangla” Selected=”True”></asp:ListItem>
<asp:ListItem Text=”English” Value=”English”></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
<tr>
<td colspan=”3″>
<table width=”100%”>
<tr>
<td width=”10px” valign=”top”>
<strong>4.</strong>
</td>
<td>
<div style=”text-align: justify;”>
I do hereby declare that to the best of my knowledge and belief the above mentioned
information is correct. I do hereby promise that if any information supplied by
me is found to be false, incomplete or any of my certificate or grade sheet is changed
or decomposed willingly and if it is proved, my application form will directly be
cancelled and I shall also be liable to obey the decision taken by the University
authority. I do hereby further undertake that I shall attend the admission test
knowing the rules and regulations written in the admission prospectus. If I get
myself admitted into this University, I shall obey the rules and regulations of
this University and during my staying in this University, I shall be bound to obey
any decision taken by the University authority.
</div>
</td>
<td width=”20px”>
</td>
<td width=”100px” align=”right”>
<asp:CheckBox ID=”CkbCondition” runat=”server” ToolTip=”Accept the codes and conditions”
Text=”Agreed” />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
<tr>
<td colspan=”3″ align=”left”>
<strong>5.</strong> Enter code shown right in text box *
</td>
</tr>
<tr>
<td colspan=”3″ align=”left”>
<table width=”700px”>
<tr>
<td>
<asp:Label ID=”lblmsgCaptcha” runat=”server” Font-Bold=”True” ForeColor=”Red” Text=”” />
<br />
<asp:TextBox ID=”txtimgcode” runat=”server” ValidationGroup=”validation” class=”form-control”
Width=”200px” />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator19″ runat=”Server” ControlToValidate=”txtimgcode”
ErrorMessage=”Code is Required !” ValidationGroup=”validation” ForeColor=”Red” />
</td>
<td>
<img height=”70″ width=”200″ src=”CImage.aspx” alt=”” />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
<tr>
<td colspan=”3″>
<div align=”right” style=”font-family: Verdana; font-size: 12px; font-style: italic;
color: Green;”>
[ Check the above ‘Check Box’; otherwise you can not preview.<br />
If problem arise then Uncheck and Check again]
</div>
<div align=”right”>
<asp:Button ID=”btnCancel” runat=”server” Text=”Cancel” CssClass=”btn btn-default”
OnClick=”btnCancel_Click” />
<asp:Button ID=”btnPreview” runat=”server” Text=”Preview” CssClass=”btn btn-default”
                                            ValidationGroup=”validation” OnClick=”btnPreview_Click” Enabled=”false” ToolTip=”Accept terms and Conditions !” />
<%–<asp:Button ID=”btnSaveData” runat=”server” Text=”Submit” OnClick=”btnSaveData_Click”
CssClass=”btn btn-default” ValidationGroup=”validation” Enabled=”false” ToolTip=”Accept terms and Conditions !” />–%>
<div id=”validation_dialog” style=”display: none”>
                                            <asp:ValidationSummary ID=”ValidationSummary1″ runat=”server” />
                                            <div style=”color: Red; font-family: Verdana; font-size: 10px; font-style: italic;”>
                                                Error: Validation (Required Field, Email) Error. Check Each Steps and Correct Values.
                                            </div>
</div>
</div>
</td>
</tr>
</table>
<br />
</fieldset>
</div>
</div>
<div id=”dialog” title=”Application Preview” style=”width: 700px;”>
                <%–<span class=”ui-icon ui-icon-alert” style=”float: left; margin: 0 7px 0 0;”></span>–%>
                <%–<fieldset>
                    <legend>Personal</legend>–%>
                <table width=”730px”>
                    <tr>
                        <td colspan=”6″>
                            <div id=”dialog-image” style=”border: 1px #ccc dashed;” title=”Picture”>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Name
                        </td>
                        <td>
                            :
                        </td>
                        <td colspan=”4″>
                            <p id=”dialog-name”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td width=”100px”>
                            Father’s Name
                        </td>
                        <td width=”5px”>
                            :
                        </td>
                        <td>
                            <p id=”fname”>
                            </p>
                        </td>
                        <td width=”100px”>
                            Mother’s Name
                        </td>
                        <td width=”5px”>
                            :
                        </td>
                        <td>
                            <p id=”mname”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Date of Birth
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”dob”>
                            </p>
                        </td>
                        <td>
                            Sex
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”sex”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Religion view
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”religion”>
                            </p>
                        </td>
                        <td>
                            Is Tribal?
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”tribal”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Tribal District
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”tbDistrict”>
                            </p>
                        </td>
                        <td>
                            Nationality
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”nationality”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Phone
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”phone”>
                            </p>
                        </td>
                        <td>
                            Mobile
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”mobile”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Email
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”email”>
                            </p>
                        </td>
                        <td>
                            Birth Place
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”birthPlace”>
                            </p>
                        </td>
                    </tr>
                </table>
                <%– </fieldset>–%>
                <br />
                <hr />
                <br />
                <table width=”730px” class=”layout display responsive-table”>
                    <tr>
                        <td>
                            Guardian Name
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”guardian”>
                            </p>
                        </td>
                        <td>
                            Relation
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”relation”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Address
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”garAddress”>
                            </p>
                        </td>
                        <td>
                            Email
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”garEmail”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mobile
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”garMobile”>
                            </p>
                        </td>
                        <td>
                            Phone
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”garPhone”>
                            </p>
                        </td>
                    </tr>
                </table>
                <br />
                <hr />
                <br />
                <table width=”730px” class=”layout display responsive-table”>
                    <tr>
                        <td>
                            Present Division
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”presentDivision”>
                            </p>
                        </td>
                        <td>
                            Present District
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”presentDistrict”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Present Thana
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”presentThana”>
                            </p>
                        </td>
                        <td>
                            Present Addresss
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”presentAddresss”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Permanent Division
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”permanentDivision”>
                            </p>
                        </td>
                        <td>
                            Permanent District
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”permanentDistrict”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Permanent Thana
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”permanentThana”>
                            </p>
                        </td>
                        <td>
                            Permanent Addresss
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”permanentAddresss”>
                            </p>
                        </td>
                    </tr>
                </table>
                <br />
                <hr />
                <br />
                <table width=”730px” class=”layout display responsive-table”>
                    <tr>
                        <th>
                            <div align=”center”>
                                Examination
                            </div>
                        </th>
                        <th align=”center”>
                            <div align=”center”>
                                Passing Year
                            </div>
                        </th>
                        <th align=”center”>
                            <div align=”center”>
                                Roll Number
                            </div>
                        </th>
                        <th align=”center”>
                            <div align=”center”>
                                Board
                            </div>
                        </th>
                        <th align=”center”>
                            <div align=”center”>
                                Institute
                            </div>
                        </th>
                    </tr>
                    <tr>
                        <td width=”80px”>
                            <strong>S.S.C/ Equiv.</strong>
                        </td>
                        <td width=”100px”>
                            <p id=”sscyear”>
                            </p>
                        </td>
                        <td width=”100px”>
                            <p id=”sscroll”>
                            </p>
                        </td>
                        <td width=”80px”>
                            <p id=”sscboard”>
                            </p>
                        </td>
                        <td>
                            <p id=”sscinstitute”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>H.S.C/ Equiv.</strong>
                        </td>
                        <td>
                            <p id=”hscyear”>
                            </p>
                        </td>
                        <td>
                            <p id=”hscroll”>
                            </p>
                        </td>
                        <td>
                            <p id=”hscboard”>
                            </p>
                        </td>
                        <td>
                            <p id=”hscinstitute”>
                            </p>
                        </td>
                    </tr>
                </table>
                <br />
                <hr />
                <br />
                <table width=”730px” class=”layout display responsive-table”>
                    <tr>
                        <th colspan=”2″>
                            <div align=”center”>
                                S.S.C
                            </div>
                        </th>
                        <th colspan=”4″>
                            <div align=”center”>
                                H.S.C
                            </div>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <div align=”center”>
                                Scale
                            </div>
                        </td>
                        <td>
                            <div align=”center”>
                                CGPA
                            </div>
                        </td>
                        <td>
                            <div align=”center”>
                                Scale
                            </div>
                        </td>
                        <td>
                            <div align=”center”>
                                CGPA
                            </div>
                        </td>
                        <td width=”80px”>
                            <div align=”center”>
                                Subject
                            </div>
                        </td>
                        <td>
                            <div align=”center”>
                                GPA
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td rowspan=”5″>
                            <div align=”center”>
                                <p id=”sscscale”>
                                </p>
                            </div>
                        </td>
                        <td rowspan=”5″>
                            <div align=”center”>
                                <p id=”sscgpa”>
                                </p>
                            </div>
                        </td>
                        <td rowspan=”5″>
                            <div align=”center”>
                                <p id=”hscscale”>
                                </p>
                            </div>
                        </td>
                        <td rowspan=”5″>
                            <div align=”center”>
                                <p id=”hscgpa”>
                                </p>
                            </div>
                        </td>
                        <td>
                            Physics
                        </td>
                        <td>
                            <div align=”center”>
                                <p id=”gpaphysics”>
                                </p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Chemistry
                        </td>
                        <td>
                            <div align=”center”>
                                <p id=”gpachemistry”>
                                </p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mathematics
                        </td>
                        <td>
                            <div align=”center”>
                                <p id=”gpamathematics”>
                                </p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            English
                        </td>
                        <td>
                            <div align=”center”>
                                <p id=”gpaenglish”>
                                </p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Total
                        </td>
                        <td>
                            <div align=”center”>
                                <p id=”gpatotal”>
                                </p>
                            </div>
                        </td>
                    </tr>
                </table>
                <br />
                <hr />
                <br />
                <table>
                    <tr>
                        <td>
                            Medium of Instructions/ Question Papers
                        </td>
                        <td>
                            :
                        </td>
                        <td>
                            <p id=”mediumInstructions”>
                            </p>
                        </td>
                    </tr>
                    <tr>
                        <td colspan=”3″>
                        </td>
                    </tr>
                    <tr>
                        <td colspan=”3″ align=”right”>
                            <div id=”dialog-signature” style=”border: 1px #ccc dashed;” title=”Picture”>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
</form>
</div>
</div>
<br />
</asp:Content>

 

B. .aspx.cs Code

protected void btnPreview_Click(object sender, EventArgs e)
{
if (Page.IsValid) // is client side validation ok?
                {
                    SubmitForm();
                }      
}

Free Barcode Generator for RDLC PDF report using C# and ASP .net and iTextSharp

Thanks to iTextSharp developer Team

Curtsy: http://www.jphellemons.nl/post/Make-a-code128-barcode-with-C-sharp-and-iTextSharp

——————————– My Code —————————-

private System.Drawing.Image CreateBarcode(string data)
{
// iTextShirp
//Bitmap barCode = new Bitmap(1, 1);
Barcode128 code128 = new Barcode128(); // barcode type
code128.Code = data;
System.Drawing.Image barCode = code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White);
//barCode.Save(Server.MapPath(“~/barcode.gif”), System.Drawing.Imaging.ImageFormat.Gif); //save file
return barCode;
}

public static byte[] ImageToByte(System.Drawing.Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}

// adding new column to datatable and assign value
System.Data.DataColumn newColumn = new System.Data.DataColumn(“barCode”, typeof(System.Byte[]));
newColumn.DefaultValue = ImageToByte(CreateBarcode(APPLICATION_SN));
dt.Columns.Add(newColumn);

————————————————————————-

I have looked for several options and libraries to generate a code128 barcode. It appears that there are three versions of code128

  • Code128A
  • Code128B
  • Code128C

128C is for digits only, 128A is for case insensitive barcodes and 128B is case sensitive. If you want to know more details, I recommend the Wikipedia page of code128.

Somehow other libraries I found did not clearly show the differences between the code128 subtypes. After some Google queries, I found out that the free open source library which I used for generating PDF’s also has capabilities for generating barcodes.

iText# (iTextSharp) is a port of the iText open source java library for PDF generation written entirely in C# for the .NET platform.

[more]So before I show you my code snippets for a generic Code128 barcode, here is the download link for the binary iText# DLL.

http-handlerAfter you have downloaded the DLL and added a reference in your project, I used a HTTP handler for handling the barcodes because I wanted to display the barcode as an image on a webpage.

I have chosen GIF over JPG for displaying barcodes online. It appears to be sharper.

So here is my implementation of the auto generated ProcessRequest method of the HTTP handler:

 

1
2
3
4
5
6
7
8
9
10
11
12
string prodCode = context.Request.QueryString.Get("code");
context.Response.ContentType = "image/gif";
if (prodCode.Length > 0)
{
    Barcode128 code128          = new Barcode128();
    code128.CodeType            = Barcode.CODE128;
    code128.ChecksumText        = true;
    code128.GenerateChecksum    = true;
    code128.Code                = prodCode;
    System.Drawing.Bitmap bm    = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
    bm.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);           
}

 

Please do not forget to add iTextSharp and iTextSharp.text.pdf to your usings!

Good luck with your Code128 Barcodes!

code128

jQuery Plugin For Lightbox-Like Form Data Preview Box – previewForm

Original post: http://www.jqueryscript.net/form/jQuery-Plugin-For-Lightbox-Like-Form-Data-Preview-Box-previewForm.html

previewForm is a lightweight yet useful jQuery plugin that popups a modal box while clicking the submit button to preview the Form Data your users input.

How to use it:

1. Create a standard html form

01 <form class="mform" id="myform" method="POST" id="myform" action="">
02 <fieldset>
03 <legend>Registeration</legend>
04 <table cellspacing="0">
05 <tbody>
06 <tr>
07 <td><label for="u_name"> Username :</label></td>
08 <td><input type="text" name="uname" id="u_name">
09 <td>
10 </tr>
11 <tr>
12 <td><label for="u_pwd"> Password :</label></td>
13 <td><input type="password" name="uname" id="u_pwd"></td>
14 </tr>
15 <tr>
16 <td><label for="u_mail"> Email :</label></td>
17 <td><input type="email" name="uname" id="u_mail"></td>
18 </tr>
19 <tr>
20 <td><label for="u_country"> Country :</label></td>
21 <td><select name="Country" id="u_country">
22 <option value="" selected="selected">Select Country</option>
23 <option value="United States">United States</option>
24 <option value="United Kingdom">United Kingdom</option>
25 <option value="Afghanistan">Afghanistan</option>
26 </select></td>
27 </tr>
28 <tr>
29 <td><span> Gender :</span></td>
30 <td><input type="radio" name="gender" id="male" value="male">
31 <label for="male"> Male</label>
32 <input type="radio" name="gender" id="female"  value="female">
33 <label for="female"> Female </label></td>
34 </tr>
35 <tr>
36 <td><label for="subscribe"> Subscribe Us : </label></td>
37 <td><input type="checkbox" id="subscribe" name="subscribe" value="yes"></td>
38 </tr>
39 <tr>
40 <td></td>
41 <td><input type="submit" value="submit"></td>
42 </tr>
43 </tbody>
44 </table>
45 </fieldset>
46 </form>

2. Include jQuery javascript library on the page

3. Include jQuery previewForm on the page, after jQuery library

1 <link rel="stylesheet" type="text/css" href="previewForm/previewForm.css" />
2 <script src="previewForm/previewForm.js"></script>

4. Call the plugin

1 <script>
2 $(document).ready(function() {
3   $('#myform').previewForm();
4 });
5 </script>

This awesome jQuery plugin is developed by aniketan. For more Advanced Usages, please check the demo page or visit the official website.

MySQL Database Backup using mysqldump command (Backup and Restore MySQL Database Using mysqldump)

Since its release in 1995, MySQL has became one of the most commonly used database in Internet world. A lot of small and medium businesses uses MySQL as their backend db.  Its popularity for use with web applications is closely tied to the popularity of PHP, which is often combined with MySQL. Wikipedia runs on MediaWiki software, which is written in PHP and uses a MySQL database. Several high-traffic web sites use MySQL for its data storage and logging of user data, including Flickr, Facebook, Wikipedia, Google, Nokia and YouTube.

MySQL provide a great command line utility to take backup of your MySQL database and restore it. mysqldump command line utility is available with MySQL installation (bin directory) that can be used to achieve this.

1. Getting backup of a MySQL database using mysqldump.

Use following command line for taking backup of your MySQL database using mysqldump utility.

mysqldump –-user [user name] –-password=[password] [database name] > [dump file]
or
mysqldump –u[user name] –p[password] [database name] > [dump file]

Example:

mysqldump –-user root –-password=myrootpassword db_test > db_test.sql
or
mysqldump –uroot –pmyrootpassword db_test > db_test.sql

2. Backup multiple databases in MySQL.

mysqldump –u[user name] –p[password] [database name 1] [database name 2] .. > [dump file]

Example:

mysqldump –-user root –-password=myrootpassword db_test db_second db_third > db_test.sql

3. Backup all databases in MySQL.

shell> mysqldump –u[user name] –p[password] –all-databases > [dump file]

4. Backup a specific table in MySQL.

shell> mysqldump --user [username] --password=[password] [database name] [table name] \
> /tmp/sugarcrm_accounts_contacts.sql

Example:

shell> mysqldump --user root --password=myrootpassword db_test customers \
> db_test_customers.sql

5. Restoring MySQL database.

The mysqldump utility is used only to take the MySQL dump. To restore the database from the dump file that you created in previous step, use mysql command.

shell> mysql --u [username] --password=[password] [database name] < [dump file]

Example:

shell> mysql --user root --password=myrootpassword new_db < db_test.sql

Do you know the other uses of mysqldump utility? Comment on this post.

mysqldump is an effective tool to backup MySQL database. It creates a *.sql file with DROP table, CREATE table and INSERT into sql-statements of the source database. To restore the database,  execute the *.sql file on destination database.  For MyISAM, use mysqlhotcopy method that we explained earlier, as it is faster for MyISAM tables.

Using mysqldump, you can backup a local database and restore it on a remote database at the same time, using a single command. In this article, let us review several practical examples on how to use mysqldump to backup and restore.

For the impatient, here is the quick snippet of how backup and restore MySQL database using mysqldump:

backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

How To Backup MySQL database

1. Backup a single database:

This example takes a backup of sugarcrm database and dumps the output to sugarcrm.sql

# mysqldump -u root -ptmppassword sugarcrm > sugarcrm.sql

# mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

The sugarcrm.sql will contain drop table, create table and insert command for all the tables in the sugarcrm database. Following is a partial output of sugarcrm.sql, showing the dump information of accounts_contacts table:

--
-- Table structure for table `accounts_contacts`
--

DROP TABLE IF EXISTS `accounts_contacts`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `accounts_contacts` (
`id` varchar(36) NOT NULL,
`contact_id` varchar(36) default NULL,
`account_id` varchar(36) default NULL,
`date_modified` datetime default NULL,
`deleted` tinyint(1) NOT NULL default '0',
PRIMARY KEY  (`id`),
KEY `idx_account_contact` (`account_id`,`contact_id`),
KEY `idx_contid_del_accid` (`contact_id`,`deleted`,`account_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;

--
-- Dumping data for table `accounts_contacts`
--

LOCK TABLES `accounts_contacts` WRITE;
/*!40000 ALTER TABLE `accounts_contacts` DISABLE KEYS */;
INSERT INTO `accounts_contacts` VALUES ('6ff90374-26d1-5fd8-b844-4873b2e42091',
'11ba0239-c7cf-e87e-e266-4873b218a3f9','503a06a8-0650-6fdd-22ae-4873b245ae53',
'2008-07-23 05:24:30',1),
('83126e77-eeda-f335-dc1b-4873bc805541','7c525b1c-8a11-d803-94a5-4873bc4ff7d2',
'80a6add6-81ed-0266-6db5-4873bc54bfb5','2008-07-23 05:24:30',1),
('4e800b97-c09f-7896-d3d7-48751d81d5ee','f241c222-b91a-d7a9-f355-48751d6bc0f9',
'27060688-1f44-9f10-bdc4-48751db40009','2008-07-23 05:24:30',1),
('c94917ea-3664-8430-e003-487be0817f41','c564b7f3-2923-30b5-4861-487be0f70cb3',
'c71eff65-b76b-cbb0-d31a-487be06e4e0b','2008-07-23 05:24:30',1),
('7dab11e1-64d3-ea6a-c62c-487ce17e4e41','79d6f6e5-50e5-9b2b-034b-487ce1dae5af',
'7b886f23-571b-595b-19dd-487ce1eee867','2008-07-23 05:24:30',1);
/*!40000 ALTER TABLE `accounts_contacts` ENABLE KEYS */;
UNLOCK TABLES;

2. Backup multiple databases:

If you want to backup multiple databases, first identify the databases that you want to backup using the show databases as shown below:

# mysql -u root -ptmppassword

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bugs               |
| mysql              |
| sugarcr            |
+--------------------+
4 rows in set (0.00 sec)

For example, if you want to take backup of both sugarcrm and bugs database, execute the mysqldump as shown below:

# mysqldump -u root -ptmppassword --databases bugs sugarcrm > bugs_sugarcrm.sql

Verify the bugs_sugarcrm.sql dumpfile contains both the database backup.

# grep -i "Current database:" /tmp/bugs_sugarcrm.sql
-- Current Database: `mysql`
-- Current Database: `sugarcrm`

3. Backup all the databases:

The following example takes a backup of  all the database of the MySQL instance.

# mysqldump -u root -ptmppassword --all-databases > /tmp/all-database.sql

4. Backup a specific table:

In this example, we backup only the accounts_contacts table from sugarcrm database.

# mysqldump -u root -ptmppassword sugarcrm accounts_contacts \
      > /tmp/sugarcrm_accounts_contacts.sql

4. Different mysqldump group options:

  • –opt is a group option, which is same as –add-drop-table, –add-locks, –create-options, –quick, –extended-insert, –lock-tables, –set-charset, and –disable-keys. opt is enabled by default, disable with –skip-opt.
  • –compact is a group option, which gives less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options –skip-add-drop-table –no-set-names –skip-disable-keys –skip-add-locks

How To Restore MySQL database

1. Restore a database

In this example, to restore the sugarcrm database, execute mysql with < as shown below. When you are restoring the dumpfilename.sql on a remote database, make sure to create the sugarcrm database before you can perform the restore.

# mysql -u root -ptmppassword

mysql> create database sugarcrm;
Query OK, 1 row affected (0.02 sec)

# mysql -u root -ptmppassword sugarcrm < /tmp/sugarcrm.sql

# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

2. Backup a local database and restore to remote server using single command:

This is a sleek option, if you want to keep a read-only database on the remote-server, which is a copy of the master database on local-server. The example below will backup the sugarcrm database on the local-server and restore it as sugarcrm1 database on the remote-server. Please note that you should first create the sugarcrm1 database on the remote-server before executing the following command.

[local-server]# mysqldump -u root -ptmppassword sugarcrm | mysql \
                 -u root -ptmppassword --host=remote-server -C sugarcrm1
[Note: There are two -- (hyphen) in front of host]

Import MySQL Dumpfile, SQL Datafile Into My Database

How can I import a MySQL dumpfile into my database? I’m using CentOS Linux 5 server. My old hosting provider gave me a data.sql file and I do have access to my Unix / Linux server via ssh. So How do I restore my data using command line over the ssh session?

You can easily restore or import MySQL data with the mysql command itself. First you need to login to your system using ssh or putty client.

Step #1: Upload File To MySQL Server

You can upload data.sql file using the sftp or scp command, enter:
$ scp data.sql vivek@example.cyberciti.biz:/home/vivek
The data.sql file will be uploaded to /home/vivek directory. Avoid using /tmp or Apache document directory such as /var/www/html as anyone can see your data on the remote server.

Step #2: Login To Remote Server

Type the following command at the shell prompt:
$ ssh loginname@example.cyberciti.biz
Replace example.cyberciti.biz with actual server name or an IP address.

Step#3: Import Datafile

Type the following command to import sql data file:
$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
In this example, import ‘data.sql’ file into ‘blog’ database using vivek as username:
$ mysql -u vivek -p -h localhost blog < data.sql

If you have a dedicated database server, replace localhost hostname with with actual server name or IP address as follows:
$ mysql -u username -p -h 202.54.1.10 databasename < data.sql
OR use hostname such as mysql.cyberciti.biz
$ mysql -u username -p -h mysql.cyberciti.biz database-name < data.sql

If you do not know the database name or database name is included in sql dump you can try out something as follows:
$ mysql -u username -p -h 202.54.1.10 < data.sql

A Note About Creating A New Database and Importing Data

In this example create a mysql database called foo and import data from bar.sql.gz as follows:

mysql -u root -p -h localhost

Sample outputs:

mysql> create database foo;
mysql> exit;

Import bar.sql.gz:

gunzip bar.sql.gz
ls -l
mysql -u root -p -h localhost foo <bar.sql

You can also create a username and password for foo database using the following syntax:

 
mysql -u root -p -h localhost

Sample outputs:

mysql> GRANT ALL ON foo.* TO NEW-USERNAME-HERE@localhost IDENTIFIED BY 'YOUR-PASSWORD-HERE';
### allow access from 192.168.1.5 too ##
mysql> GRANT ALL ON foo.* TO NEW-USERNAME-HERE@192.168.1.5 IDENTIFIED BY 'YOUR-PASSWORD-HERE';
mysql> quit;

Restore Database From the Command Prompt

If you are moving your data to a new server, or you have removed the old database completely you can restore it using the code below. This will only work if the database does not already exist:
mysql - u user_name -p your_password database_name < file_name.sql

Or using our example from the previous page:

mysql - u bobbyjoe -p happy234 BobsData < BobBackup.sql

If your database already exists and you are just restoring it, try this line instead:

mysqlimport -u user_name -p your_password database_name file_name.sql

Or using our example again:

mysqlimport -u bobbyjoe -p happy234 BobsData BobBackup.sql

How to Connect to MySQL Using C#

Introduction

This article shows you how to connect to a MySQL database using the MySQL Connector for .NET. I will also show you how you can update MySQL database records using C#.

Prerequisites

  • Install Visual Studio 2008 or Visual Studio 2010
  • Install MySQL database on your local machine
  • MySQL database admin tool that allows you to create a database and run SQL statements. I am using phpMyAdmin which is a web interface.
  • Download and install MySQL Connector.

Getting Started

Run the XAMPP application and it will automatically install Apache server, MySQL database, and FileZilla. After installing check whether these services are running or not. The following XAMPP control panel shows which of those services are currently running.

Now the following steps will show how to connect to a MySQL database using C#.

Step 1

Open MySQL Admin page and create a new database.

Step 2

After creating the new database, create a new table.

Step 3

After creating the new table, open Visual Studio and click on New Project and name the project. It will open the new project, then click on Solution Explorer (F4), right click on “Reference” to add a new reference into the project. Reference those two .dll files to the project (MySql.dll (Win apps), MySql.web.dll (Web apps)).

Step 4

Add namespace to the project.

Step 5

Create a MySQL connection string.

Step 6

The following code will insert the data into MySQL table.

Step 7

The following function will load the data from the table and bind it into a GridView.

Step 8

The final result is shown on the window form: