Asp.net timer control
Asp.net timer control sample
http://forums.asp.net/t/1330209.aspx
Oct 14, 2008
ChangeApprovalStatus in sqlserver
USE [TEMPDB]
GO
/****** Object: StoredProcedure [dbo].[ChangeApprovalStatus] Script Date: 11/25/2008 09:55:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ChangeApprovalStatus]
@strCompanyXML xml
AS
SET NOCOUNT ON
DECLARE @XMLDocPointer INT
DECLARE @RowCount INT
DECLARE @Error INT
DECLARE @Msg VARCHAR(100)
IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[#tmpCompaniesXML]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].#tmpCompaniesXML
CREATE TABLE #tmpCompaniesXML(CompanyID VARCHAR(10))
IF @strCompanyXML IS NOT NULL
BEGIN
EXEC sp_xml_preparedocument @XMLDocPointer OUTPUT, @strCompanyXML
INSERT INTO #tmpCompaniesXML
SELECT * FROM OPENXML(@XMLDocPointer,'/root/company')
WITH (
[id] [varchar](10)
)
EXEC sp_xml_removedocument @XMLDocPointer
END
BEGIN TRANSACTION TRAN_UPD_TRKG
UPDATE T_Tracking
SET IsSFE=0,IsSynchronised=0
WHERE CompanyID IN (SELECT CompanyID FROM #tmpCompaniesXML)
SELECT @RowCount=@@ROWCOUNT,@Error=@@ERROR
IF @Error != 0 OR @Rowcount = 0
BEGIN
ROLLBACK TRANSACTION TRAN_UPD_TRKG
SET @Msg = 'Unable to update entry in T_Tracking'
RAISERROR(@Msg,16,1)
RETURN 0
END
SELECT @RowCount
COMMIT TRANSACTION TRAN_UPD_TRKG
IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[#tmpCompaniesXML]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].#tmpCompaniesXML
RETURN 1
GO
/****** Object: StoredProcedure [dbo].[ChangeApprovalStatus] Script Date: 11/25/2008 09:55:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[ChangeApprovalStatus]
@strCompanyXML xml
AS
SET NOCOUNT ON
DECLARE @XMLDocPointer INT
DECLARE @RowCount INT
DECLARE @Error INT
DECLARE @Msg VARCHAR(100)
IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[#tmpCompaniesXML]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].#tmpCompaniesXML
CREATE TABLE #tmpCompaniesXML(CompanyID VARCHAR(10))
IF @strCompanyXML IS NOT NULL
BEGIN
EXEC sp_xml_preparedocument @XMLDocPointer OUTPUT, @strCompanyXML
INSERT INTO #tmpCompaniesXML
SELECT * FROM OPENXML(@XMLDocPointer,'/root/company')
WITH (
[id] [varchar](10)
)
EXEC sp_xml_removedocument @XMLDocPointer
END
BEGIN TRANSACTION TRAN_UPD_TRKG
UPDATE T_Tracking
SET IsSFE=0,IsSynchronised=0
WHERE CompanyID IN (SELECT CompanyID FROM #tmpCompaniesXML)
SELECT @RowCount=@@ROWCOUNT,@Error=@@ERROR
IF @Error != 0 OR @Rowcount = 0
BEGIN
ROLLBACK TRANSACTION TRAN_UPD_TRKG
SET @Msg = 'Unable to update entry in T_Tracking'
RAISERROR(@Msg,16,1)
RETURN 0
END
SELECT @RowCount
COMMIT TRANSACTION TRAN_UPD_TRKG
IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[#tmpCompaniesXML]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].#tmpCompaniesXML
RETURN 1
delete with stored procedure in sqlserver
USE [RICH]
GO
/****** Object: StoredProcedure [dbo].[sp_deleteCohort] Script Date: 11/25/2008 09:53:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[sp_deleteCohort]
@cohort as varchar(50)
AS
BEGIN
DELETE FROM RICHS2K8
WHERE
Cohort=@cohort
END
GO
/****** Object: StoredProcedure [dbo].[sp_deleteCohort] Script Date: 11/25/2008 09:53:11 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[sp_deleteCohort]
@cohort as varchar(50)
AS
BEGIN
DELETE FROM RICHS2K8
WHERE
Cohort=@cohort
END
Opening a an aspx page in a new window.
Button1.Attributes.Add("onclick","window.open('Popup.aspx');return false");
or
Page.ClientScript.RegisterStartupScript(this.GetType(),"open","window.open('Popup.aspx');",true);
or
Page.ClientScript.RegisterStartupScript(this.GetType(),"open","window.open('Popup.aspx');",true);
Sending email through asp.net
namespace :
using System.Net.Mail;
{
SmtpClient SMTP = new SmtpClient();
SMTP.Host = "localhost"; //if you have mailserver IP address replace to localhost
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("info@sample.com");
string Toadd = username.Text;//sample@sample.com
message.To.Add(Toadd.ToString());
message.Subject = "Registration successful";
message.Body = "Thankyou for Registration!
Following are your account details,";
message.IsBodyHtml = true;
SMTP.Send(message);
}
ref:http://forums.asp.net/t/1330871.aspx
using System.Net.Mail;
{
SmtpClient SMTP = new SmtpClient();
SMTP.Host = "localhost"; //if you have mailserver IP address replace to localhost
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("info@sample.com");
string Toadd = username.Text;//sample@sample.com
message.To.Add(Toadd.ToString());
message.Subject = "Registration successful";
message.Body = "Thankyou for Registration!
Following are your account details,";
message.IsBodyHtml = true;
SMTP.Send(message);
}
ref:http://forums.asp.net/t/1330871.aspx
How to filter extension file using fileupload?
function CheckFileExistence()
{
var filePath=document.getElementById('<%= this.filUpload.ClientID %>').value;
if(filePath.length<1)
{
alert("File Name Can not be empty");return false;
}
var validExtensions = new Array();var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
validExtensions[0] = 'jpg';
validExtensions[1] = 'jpeg';
validExtensions[2] = 'bmp';
validExtensions[3] = 'png';
validExtensions[4] = 'gif';
validExtensions[5] = 'tif'; validExtensions[6] = 'eps';
for(var i = 0; i < validExtensions.length; i++) {
if(ext == validExtensions[i])return true;
}
alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
return false;
}
use the function into button like OnClientClick="return CheckFileExistence()"
{
var filePath=document.getElementById('<%= this.filUpload.ClientID %>').value;
if(filePath.length<1)
{
alert("File Name Can not be empty");return false;
}
var validExtensions = new Array();var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
validExtensions[0] = 'jpg';
validExtensions[1] = 'jpeg';
validExtensions[2] = 'bmp';
validExtensions[3] = 'png';
validExtensions[4] = 'gif';
validExtensions[5] = 'tif'; validExtensions[6] = 'eps';
for(var i = 0; i < validExtensions.length; i++) {
if(ext == validExtensions[i])return true;
}
alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
return false;
}
use the function into button like OnClientClick="return CheckFileExistence()"
Subscribe to:
Posts (Atom)