SELECT TOP 1 [Salary] FROM ( SELECT DISTINCT TOP 2 [Salary] FROM [dbo].[Employee] ORDER BY [Salary] DESC ) temp ORDER BY [Salary]
Monday, 26 December 2011
Nth Highest Salary Record In Sql Server
Thursday, 15 December 2011
Client Side Validation in asp.net, Required Field,MobileNo,Blank Field
<script language="javascript" type="text/javascript">
function validate() {
if (document.getElementById("<%=txtFirstName.ClientID%>").value == "") {
alert("Name Field can not be blank");
document.getElementById("<%=txtFirstName.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtEmail.ClientID%>").value == "") {
alert("Email Field can not be blank");
document.getElementById("<%=txtEmail.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtPhone.ClientID%>").value == "") {
alert(" Phone Field can not be blank");
document.getElementById("<%=txtPhone.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtEmergencyContact.ClientID%>").value == "") {
alert("Emergency Contact Field can not be blank");
document.getElementById("<%=txtEmergencyContact.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtAge.ClientID%>").value == "") {
alert("Age Field can not be blank");
document.getElementById("<%=txtAge.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtPreferred.ClientID%>").value == "") {
alert("Preferred Partner Field can not be blank");
document.getElementById("<%=txtPreferred.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtPhone.ClientID%>").value == "") {
alert("Mobile No is not valid");
document.getElementById("<%=txtPhone.ClientID%>").focus();
return false;
}
var digits = /^([0-9]{10})$/;
var digitsid = document.getElementById("<%=txtPhone.ClientID %>").value;
var digitsArray = digitsid.match(digits);
var temp;
if (digitsArray == null) {
alert("Your mobile seems incorrect. Please try again.");
document.getElementById("<%=txtPhone.ClientID %>").focus();
return false;
}
var digits = /^([0-9]{10})$/;
var digitsid = document.getElementById("<%=txtEmergencyContact.ClientID %>").value;
var digitsArray = digitsid.match(digits);
var temp;
if (digitsArray == null) {
alert("Your Emergency Contact seems incorrect. Please try again.");
document.getElementById("<%=txtEmergencyContact.ClientID %>").focus();
return false;
}
return true;
}
</script>
In Submit Button We have
<asp:Button CssClass="button" ID="btnNameEmail" runat="server" Text="Submit" OnClick="btnNameEmail_Click" OnClientClick ="return Validate(this)" />
Call the JavaScript Function
function validate() {
if (document.getElementById("<%=txtFirstName.ClientID%>").value == "") {
alert("Name Field can not be blank");
document.getElementById("<%=txtFirstName.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtEmail.ClientID%>").value == "") {
alert("Email Field can not be blank");
document.getElementById("<%=txtEmail.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtPhone.ClientID%>").value == "") {
alert(" Phone Field can not be blank");
document.getElementById("<%=txtPhone.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtEmergencyContact.ClientID%>").value == "") {
alert("Emergency Contact Field can not be blank");
document.getElementById("<%=txtEmergencyContact.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtAge.ClientID%>").value == "") {
alert("Age Field can not be blank");
document.getElementById("<%=txtAge.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtPreferred.ClientID%>").value == "") {
alert("Preferred Partner Field can not be blank");
document.getElementById("<%=txtPreferred.ClientID%>").focus();
return false;
}
if (document.getElementById("<%=txtPhone.ClientID%>").value == "") {
alert("Mobile No is not valid");
document.getElementById("<%=txtPhone.ClientID%>").focus();
return false;
}
var digits = /^([0-9]{10})$/;
var digitsid = document.getElementById("<%=txtPhone.ClientID %>").value;
var digitsArray = digitsid.match(digits);
var temp;
if (digitsArray == null) {
alert("Your mobile seems incorrect. Please try again.");
document.getElementById("<%=txtPhone.ClientID %>").focus();
return false;
}
var digits = /^([0-9]{10})$/;
var digitsid = document.getElementById("<%=txtEmergencyContact.ClientID %>").value;
var digitsArray = digitsid.match(digits);
var temp;
if (digitsArray == null) {
alert("Your Emergency Contact seems incorrect. Please try again.");
document.getElementById("<%=txtEmergencyContact.ClientID %>").focus();
return false;
}
return true;
}
</script>
In Submit Button We have
<asp:Button CssClass="button" ID="btnNameEmail" runat="server" Text="Submit" OnClick="btnNameEmail_Click" OnClientClick ="return Validate(this)" />
Call the JavaScript Function
Friday, 2 December 2011
How to select Only One CheckBox In Grid View
<script type="text/javascript">
function CheckOne(obj) {
var grid = obj.parentNode.parentNode.parentNode;
var inputs = grid.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
if (obj.checked && inputs[i] != obj && inputs[i].checked) {
inputs[i].checked = false;
}
}
}
}
</script>
and Use This
<asp:CheckBox ID="chkSelect" runat="server" onclick ="CheckOne(this)"
/>
function CheckOne(obj) {
var grid = obj.parentNode.parentNode.parentNode;
var inputs = grid.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
if (obj.checked && inputs[i] != obj && inputs[i].checked) {
inputs[i].checked = false;
}
}
}
}
</script>
and Use This
<asp:CheckBox ID="chkSelect" runat="server" onclick ="CheckOne(this)"
/>
Thursday, 24 November 2011
Password recovery with .NET using C#
I have this website with a login and a password recovery link. When I click the "forgot my password" link it takes me to a page which asks for username and security question answer. When I fill it out and hit submit. I am taken to a page that tells me the email was sent successfully but when I check my email, there is nothing there.
I'm hoping someone can tell me why I am not getting the password send to me. Here is my code.
I'm hoping someone can tell me why I am not getting the password send to me. Here is my code.
<%@ Page Language="C#" MasterPageFile="~/BlogMasterPage.master" %> <%@ Import Namespace="System.Net.Mail" %> <script runat="server"> protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { MailMessage msg = new MailMessage(); msg.From = new MailAddress("xxxxxxxxxx@gmail.com", "name"); msg.To.Add(new MailAddress("xxxxxxxxx@hotmail.com", "name")); msg.Subject = "Test Mail"; msg.Body = "It's another test, yet again!"; msg.IsBodyHtml = false; msg.Priority = MailPriority.High; SmtpClient smtpClient = new SmtpClient(); smtpClient.EnableSsl = true; smtpClient.Send(e.Message); e.Cancel = true; } </script> <asp:Content ID="Content1" ContentPlaceHolderID="BlogMasterPage" runat="server"> <br /> <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" OnSendingMail="PasswordRecovery1_SendingMail"> <MailDefinition BodyFileName="" From="xxxxxxxxxxx@gmail.com" Subject="Password Recovery"> </MailDefinition> </asp:PasswordRecovery> <br /> </asp:Content> <system.net> <mailSettings> <smtp from="xxxxxxxxxxxxx@gmail.com"> <network host="smtp.gmail.com" password="xxxxxxx" userName="xxxxxxxxxxxxx@gmail.com" /> </smtp> </mailSettings> </system.net>
Wednesday, 16 November 2011
How to add Auto Increment Serial No in Grid View in C#.net
<asp:GridView ID="GrdDetailreport" runat="server" AlternatingRowStyle-CssClass="alt" Style="width: 70%" >
<Columns>
<asp:TemplateField HeaderText="Serial Number">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<Columns>
<asp:TemplateField HeaderText="Serial Number">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Subscribe to:
Posts (Atom)