http://dotnetawesome.blogspot.in/2014/03/how-to-make-scrollable-gridview-with-fixed-header-with-freeze-row.html
Tuesday, 4 March 2014
Saturday, 1 March 2014
MVC interview questions
http://www.codeproject.com/Articles/556995/MVC-interview-questions-with-answers#What_is_MVC(Model_view_controller)
Wednesday, 20 November 2013
Multi select dropdown-check-list
https://code.google.com/p/dropdown-check-list/
Description
Dropdown Check List is a javascript plugin based on the jQuery library that transforms a regular select html element into a dropdown checkbox list.
Disclaimer
Whilst Warren Omohundro has done an excellent job in keeping DDCL maintained after Adrian faced time constraints, he has also found that he is short of time. I (Richard Bairwell) have therefore stepped forward to try and maintain DDCL in at least the short to medium term. However, if any body feels they can devote time to maintaining and developing DDCL, then feel free to get in contact.
Usage
$("#select_id").dropdownchecklist();
The existing select element with id 'select_id' is replaced by a dropdown checkbox list widget.
See the DEMO page for a detailed description, documentation, and live examples. This page is based on the functionality in the current, downloadable release.
See the TESTCASE page for a series of test cases that exercise DDCL in various ways. This page is based directly on the most current version checked into SVN, not on the stable release version.
Download
From download location.
Limitations
1) Keyboard / Tab processing is iffy at best. I have found no reliable way of detecting loss of focus to another component in order to force an auto-close of the dropdown.
2) <LABEL> tags associated with the underlying <SELECT> just do not work, since the <LABEL> is wired to the original <SELECT>, not the DDCL component. In particular, do not include the original <SELECT> within the span of the <LABEL> tag itself.
3) IFrame support is questionable
4) DDCL calculates size and position on widget initialization. This only operates properly if the wrapper elements containing the <SELECT> are not hidden. Therefore, the use of DDCL within dynamic components that hide/show the wrapper element is problematic.
5) DDCL V1.4 was the last tested with IE6. No future version of DDCL will test with IE6.
6) DDCL V1.4 is NOT compatible with jQuery 1.8
History
See change history.
Version 1.4 - requires jQuery 1.6.1, ui 1.8.13
Version 1.3 - copy of <OPTION> styling into the dynamic components
Version 1.2 (which never made it out of QA) - the various pop-up positioning problems reported in the issue log have been addressed
Version 1.1 - DDCL now based on jQuery 1.4.2, ui 1.8.4
Version 1.0 - the most significant difference between version 1.0 and 0.9 is the switch-over to jQuery ThemeRoller based styling. While many of the 0.9 class tags are still in place, some have been retired in favor of ThemeRoller settings. If you have customized your CSS based on 0.9, you will likely have to change some of your class name pattern matches.
License
Licensed like jQuery, see http://docs.jquery.com/Licensing
Acknowledgments
Due to time constraints, Adrian has had to step back from the active support of DDCL. But as of 09Sept2010, he has graciously allowed me to step in and re-activate the project.
Adrian, many thanks from all your users. Warren C. Omohundro - Ittrium, LLC
How to Send an Email with Verification link to user in Asp.net after registration
http://articlemirror.blogspot.in/2013/06/how-to-send-email-with-verification.html
How to Send an Email with Verification link to user in Asp.net after registration
Posted by Vijay Saklani on 11:58 AM with 2 comments
Introduction: In this post I will try to explain how we can send the verification Email with link to user after registration in Asp.net.
Description:
In the previous article i have explained How to Send Email with Attachment in Asp.net ,How to send Email in Asp.net using Web.config.
In the previous article i have explained How to Send Email with Attachment in Asp.net ,How to send Email in Asp.net using Web.config.
Here I created a table USER_REGISTRATION. USER_ID is primary key.
USER_ID
|
int
|
USERNAME
|
varchar(50)
|
FIRST_NAME
|
varchar(50)
|
LAST_NAME
|
varchar(50)
|
EMAIL
|
varchar(50)
|
IS_APPROVE
|
bit
|
PASSWORD
|
varchar(50)
|
Add two webforms to project User_registration.aspx and Verification.aspx.
Drag and drop the controls from Toolbox to .aspx page.
Drag and drop the controls from Toolbox to .aspx page.
<table border="1px solid" width="330px">
<tr><b style="color:Blue;">Send Verification link to User after Registartion</b></tr>
<tr><td>Username:</td><td>
<asp:TextBox ID="txtusername" runat="server"></asp:TextBox></td></tr>
<tr><td>First Name:</td><td>
<asp:TextBox ID="txtfirst" runat="server"></asp:TextBox></td></tr>
<tr><td>Last Name:</td><td>
<asp:TextBox ID="txtlast" runat="server"></asp:TextBox></td></tr>
<tr><td>Email:</td><td>
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox></td></tr>
<tr><td>Password:</td><td>
<asp:TextBox ID="txtpassword" runat="server" TextMode="Password"></asp:TextBox></td></tr>
<tr><td>Confirm Password:</td><td>
<asp:TextBox ID="txtconfirm" runat="server" TextMode="Password"></asp:TextBox></td></tr>
<tr><td> </td><td>
<asp:Button ID="Button1" runat="server" Text="Register" OnClientClick="return ValidateEmail();"
onclick="Button1_Click" /></td></tr>
</table>
Add the below given Javascript between Head Tag to validate the Email Textbox:
<script language="javascript" type="text/javascript">
function ValidateEmail() {
var emailRegex = new RegExp(/^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$/i);
var emailAddress = document.getElementById("<%= txtemail.ClientID %>").value;
var valid = emailRegex.test(emailAddress);
if (!valid) {
alert("Please Enter Valid Email address");
return false;
} else
return true;
}
</script>
Now go to .aspx.cs page and write the below mention code:
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Net.Mail;
using System.Net;
SqlConnection con = newSqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (IsUsernameEmailExist())
{
Messagebox("Username/Email address already exists. Please try another");
return;
}
if (txtpassword.Text == txtconfirm.Text)
{
SqlCommand cmd = new SqlCommand("insert into USER_REGISTRATION (USERNAME,FIRST_NAME,LAST_NAME,EMAIL,PASSWORD) values(@USERNAME,@FIRST_NAME,@LAST_NAME,@EMAIL,@PASSWORD)", con);
cmd.Parameters.AddWithValue("@USERNAME", txtusername.Text);
cmd.Parameters.AddWithValue("@FIRST_NAME", txtfirst.Text);
cmd.Parameters.AddWithValue("@LAST_NAME", txtlast.Text);
cmd.Parameters.AddWithValue("@EMAIL", txtemail.Text);
cmd.Parameters.AddWithValue("@PASSWORD", txtpassword.Text);
cmd.ExecuteNonQuery();
Sendemail();
Clear();
Messagebox("User Register Successfully");
cmd.Dispose();
}
else
{
Messagebox("Passowrd Not Match");
}
}
public void Sendemail()
{
string ActivationUrl;
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("demo@gmail.com", "Saklani");
message.To.Add(txtemail.Text);
message.Subject = "Verification Email";
ActivationUrl = Server.HtmlEncode("http://localhost:9525/Important_Testing/Verification.aspx?USER_ID=" + GetUserID(txtemail.Text));
message.Body = "<a href='"+ActivationUrl+"'>Click Here to verify your acount</a>";
message.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("demo@gmail.com","demo123");
smtp.EnableSsl = true;
smtp.Send(message);
}
catch (Exception ex)
{
}
}
private string GetUserID(string Email)
{
SqlCommand cmd = new SqlCommand("SELECT USER_ID FROM USER_REGISTRATION WHERE EMAIL=@EMAIL", con);
cmd.Parameters.AddWithValue("@EMAIL", txtemail.Text);
string UserID = cmd.ExecuteScalar().ToString();
return UserID;
}
private bool IsUsernameEmailExist()
{
SqlCommand cmd = new SqlCommand("Select * from USER_REGISTRATION where USERNAME='" + txtusername.Text + "' or EMAIL='" + txtemail.Text + "'", con);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
private void Messagebox(string Message)
{
Label lblMessageBox = new Label();
lblMessageBox.Text =
"<script language='javascript'>" + Environment.NewLine +
"window.alert('" + Message + "')</script>";
Page.Controls.Add(lblMessageBox);
}
public void Clear()
{
txtusername.Text = "";
txtfirst.Text = "";
txtlast.Text = "";
txtemail.Text = "";
txtpassword.Text = "";
txtconfirm.Text = "";
}
In VB (.aspx.vb)
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Net.Mail
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("con").ToString())
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.Load
If con.State = ConnectionState.Closed Then
con.Open()
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) HandlesButton1.Click
If IsUsernameEmailExist() Then
Messagebox("Username/Email address already exists. Please try another")
Return
End If
If txtpassword.Text = txtconfirm.Text Then
Dim cmd As New SqlCommand("insert into USER_REGISTRATION (USERNAME,FIRST_NAME,LAST_NAME,EMAIL,PASSWORD) values(@USERNAME,@FIRST_NAME,@LAST_NAME,@EMAIL,@PASSWORD)", con)
cmd.Parameters.AddWithValue("@USERNAME", txtusername.Text)
cmd.Parameters.AddWithValue("@FIRST_NAME", txtfirst.Text)
cmd.Parameters.AddWithValue("@LAST_NAME", txtlast.Text)
cmd.Parameters.AddWithValue("@EMAIL", txtemail.Text)
cmd.Parameters.AddWithValue("@PASSWORD", txtpassword.Text)
cmd.ExecuteNonQuery()
Sendemail()
Messagebox("User Register Successfully")
cmd.Dispose()
Else
Messagebox("Passowrd Not Match")
End If
End Sub
Private Function IsUsernameEmailExist() As Boolean
Dim cmd As New SqlCommand(("Select * from USER_REGISTRATION where USERNAME='" + txtusername.Text & "' or EMAIL='") + txtemail.Text & "'", con)
cmd.ExecuteNonQuery()
Dim dt As New DataTable()
Dim adp As New SqlDataAdapter(cmd)
adp.Fill(dt)
If dt.Rows.Count > 0 Then
Return True
Else
Return False
End If
End Function
Private Sub Messagebox(ByVal Message As String)
Dim lblMessageBox As New Label()
lblMessageBox.Text = "<script language='javascript'>" + Environment.NewLine &"window.alert('" & Message & "')</script>"
Page.Controls.Add(lblMessageBox)
End Sub
Public Sub Sendemail()
Dim ActivationUrl As String
Try
Dim message As New MailMessage()
message.From = New MailAddress("demo@gmail.com", "Saklani")
message.[To].Add(txtemail.Text)
message.Subject = "Verification Email"
ActivationUrl = Server.HtmlEncode("http://localhost:9525/Important_Testing/Verification.aspx?USER_ID=" & GetUserID(txtemail.Text))
message.Body = "<a href='" & ActivationUrl & "'>Click Here to verify your acount</a>"
message.IsBodyHtml = True
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.Port = 587
smtp.Credentials = New System.Net.NetworkCredential("demo@gmail.com", "demo123")
smtp.EnableSsl = True
smtp.Send(message)
Catch ex As Exception
End Try
End Sub
Private Function GetUserID(ByVal Email As String) As String
Dim cmd As New SqlCommand("SELECT USER_ID FROM USER_REGISTRATION WHERE EMAIL=@EMAIL", con)
cmd.Parameters.AddWithValue("@EMAIL", txtemail.Text)
Dim UserID As String = cmd.ExecuteScalar().ToString()
Return UserID
End Function
After that now check the QueryString value on Verification.aspx page. Write the below given code on .aspx.cspage:
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
SqlConnection con = newSqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
string USERID, USERNAME;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["USER_ID"] != null)
{
USERID = Request.QueryString["USER_ID"];
SqlCommand cmd = new SqlCommand("Update USER_REGISTRATION set IS_APPROVE=1 where USER_ID=@USER_ID", con);
cmd.Parameters.AddWithValue("@USER_ID", USERID);
con.Open();
cmd.ExecuteNonQuery();
Response.Write(Request.QueryString["USER_ID"]);
}
}
In VB (.aspx.vb)
Imports System.Data
Imports System.Data.SqlClient
Private con As New SqlConnection(ConfigurationManager.ConnectionStrings("con").ToString())
Private USERID As String, USERNAME As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) HandlesMe.Load
If Request.QueryString("USER_ID") IsNot Nothing Then
USERID = Request.QueryString("USER_ID")
Dim cmd As New SqlCommand("Update USER_REGISTRATION set IS_APPROVE=1 where USER_ID=@USER_ID", con)
cmd.Parameters.AddWithValue("@USER_ID", USERID)
con.Open()
cmd.ExecuteNonQuery()
Response.Write(Request.QueryString("USER_ID"))
End If
End Sub
Now run the project and check the result.
Subscribe to:
Posts (Atom)