|
<script type="text/javascript">
$(document).ready(function () {
var url = location.href.substring(location.href.lastIndexOf("/") + 1);
var page = url.substring(0, url.lastIndexOf("."));
var query = url.substring(url.indexOf("?") + 1);
query = query.substring(query.indexOf("=") + 1);
if ((query == "" || query == undefined) && (page == "" || page == undefined)) {
$('.ligreenbg').addClass(" ");
return;
}
if (page == "PageO") {
$('.ord').addClass('ligreenbg');
}
else if ((page == "pg1") || (page == "pg2") || (page == "pg3") || (page == "pg4") || (page == "pg5") || (page == "pg6") || (page == "pg7") || (page == "pg8") || (page == "pg9") || (page == "pg10") || (page == "pg11")) {
$('.mast').addClass('ligreenbg');
}
else if ((page == "pgg1") || (page == "pgg2") || (page == "pgg3")) {
$('.pro').addClass('ligreenbg');
}
else if (page == "user") {
$('.use').addClass('ligreenbg');
}
});
</script>
<ul id="css3menu1">
<li class="Submenu ord" ><a href='<%= Page.ResolveUrl("~")%>AspxPages/PageO.aspx'
target="_parent">PageO</a></li>
<li class="topmenu mast"><a href="#"><span>Menu1</span></a>
<ul id="Submenu" class="topmenu1">
<li><a href='<%= Page.ResolveUrl("~")%>AspxPages/pg1.aspx'>pg1</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg2.aspx'>pg2</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg3.aspx'>pg3</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg4.aspx'>pg4</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg5.aspx'>pg5</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg6.aspx'>pg6</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg7.aspx'>pg7</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg8.aspx'>pg8</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg9.aspx'>pg9</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg10.aspx'>pg10</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>Masters/pg11.aspx'>pg11</a></li>
</ul>
</li>
<li class="topmenu pro"><a href="#"><span>Menu2</span></a>
<ul id="Submenu">
<li><a href='<%= Page.ResolveUrl("~")%>AspxPages/pgg1.aspx'>pgg1;/a></li>
<li><a href='<%= Page.ResolveUrl("~")%>AspxPages/pgg2.aspx'>pgg2</a></li>
<li><a href='<%= Page.ResolveUrl("~")%>AspxPages/pgg3.aspx'>pgg3</a></li>
</ul>
</li>
<li class="toplast use"><a href="#"><span>Menu3</span></a>
<ul id="Submenu">
<li><a href='<%= Page.ResolveUrl("~")%>Account/user.aspx'>user</a></li>
</ul>
</li>
</ul>
Thanks & Regards
Sanwar
|
|
|
|
|
<a href='<%= Page.ResolveUrl("~")%>AspxPages/ItemUploadForm.aspx'>Tally Upload</a>
Thanks & Regards
Sanwar
|
|
|
|
|
<script language="javascript">
function test(text,e, long) {
var maxlength = new Number(long); // Change number to your max length.
if (document.getElementById('<%=tstPaymentInsetr.ClientID%>').value.length > maxlength) {
if (!checkSpecialKeys(e)) {
text.value = text.value.substring(0, maxlength);
alert("Please enter only maximum 500 character limit.");
}
}
}
function checkSpecialKeys(e) {
if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 35 && e.keyCode != 36 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40)
return false;
else
return true;
}
</script>
<asp:TextBox ID="tstPaymentInsetr" runat="server" TextMode="MultiLine" Columns="30" Rows="3" MaxLength="500"
onKeyUp="return test(this,event,500)" onKeyPress="return test(this,event,500)"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="tstPaymentInsetr"
ErrorMessage="Please enter only maximum 500 character limit."
ValidationExpression="[\s\S]{1,500}"></asp:RegularExpressionValidator>
Thanks & Regards
Sanwar
|
|
|
|
|
Create proc spname
@ID nvarchar(500)
as
SELECT * FROM Yourtablename Where (',' + @ID +',' LIKE '%,' + CONVERT(VARCHAR(10), UserContactListId) + ',%')
Thanks & Regards
Sanwar
|
|
|
|
|
OnClientClick="javascript:Page_ClientValidate(); if (Page_IsValid==true) { this.disabled=true; }"
Thanks & Regards
Sanwar
|
|
|
|
|
use this name space --> using System.Text.RegularExpressions;
then use this code ...
string input = "sw-100-100";
Match mat = Regex.Match(input, @"sw-100-.*", RegexOptions.IgnoreCase);
if (mat.Success)
{
........
}
Thanks & Regards
Sanwar
|
|
|
|
|
exec sp_msforeachtable @command1="print '?'"
exec sp_msforeachtable N'SELECT [?] = count(*) FROM Movies.? '
Thanks & Regards
Sanwar
|
|
|
|
|
SELECT 'USE [' + db_name() +']';-- Check using database name
SELECT 'ALTER TABLE ' + -- Remove foreigh key constaint of alll tables in using databse
'[' + sche.name + '].[' +tbl.name + ']' +
' DROP CONSTRAINT [' + fK.name + ']'
FROM sys.foreign_keys fK
INNER JOIN sys.TABLES tbl ON fK.parent_object_id=tbl.object_id
INNER JOIN sys.schemas sche ON tbl.schema_id=sche.schema_id
WHERE tbl.is_ms_shipped=0;
SELECT 'TRUNCATE TABLE ' + '[' + sche.name + '].[' + tbl.name + ']' -- Truncate all table in a Using database
FROM sys.TABLES tbl
INNER JOIN sys.schemas sche ON tbl.schema_id=sche.schema_id
WHERE tbl.is_ms_shipped=0;
SELECT 'ALTER TABLE ' + -- Recreate foreign key containt all table in a using database
'[' + sche.name + '].[' + tbl.name + ']' +
' ADD CONSTRAINT [' + f.name + ']' +
' FOREIGN KEY (' +
Stuff( (SELECT ', ['+col_name(fk.parent_object_id, fk.parent_column_id) +']'
FROM sys.foreign_key_columns fk
WHERE constraint_object_id = f.object_id
ORDER BY constraint_column_id
FOR XML Path('')
), 1,2,'') + ')' +
' REFERENCES [' +
object_schema_name(f.referenced_object_id)+'].['+object_name(f.referenced_object_id) + '] (' +
Stuff((SELECT ', ['+col_name(fc.referenced_object_id, fc.referenced_column_id)+']'
FROM sys.foreign_key_columns fc
WHERE constraint_object_id = f.object_id
ORDER BY constraint_column_id
FOR XML Path('')),
1,2,'') +
')' +
' ON DELETE ' + REPLACE(f.delete_referential_action_desc, '_', ' ') +
' ON UPDATE ' + REPLACE(f.update_referential_action_desc , '_', ' ') collate database_default
FROM sys.foreign_keys f
INNER JOIN sys.TABLES tbl ON f.parent_object_id=tbl.object_id
INNER JOIN sys.schemas sche ON tbl.schema_id=sche.schema_id
WHERE tbl.is_ms_shipped=0;
Thanks & Regards
Sanwar
|
|
|
|
|
private string DecimaltoBinary(int Number)
{
string res1 = "999";
int args = Number;
while (args > 1)
{
int arg1 = Convert.ToInt32(args / 2);
int arg2 = args % 2;
args = arg1;
if (res1 == "999")
{
res1 = arg2.ToString();
}
else
{
res1 = arg2.ToString() + res1.ToString();
}
}
if (args == 1 && res1 != "999")
{
res1 = args.ToString() + res1.ToString();
}
else if (args == 0 && res1 == "999")
{
res1 = "0";
}
else if (res1 == "999")
{
res1 = "1";
}
int ll = res1.Length;
while (ll % 4 != 0)
{
res1 = "0" + res1;
ll = res1.Length;
}
return res1;
}
Thanks & Regards
Sanwar
|
|
|
|
|
<a href='mailto:To@domain.com,AnotherTo@domain.com?CC=cc@domain.com,Anothercc@domain.com&BCC=Bcc@domain.com,AnotherBcc@domain.com&Subject=enter your subject;&Body=enter mail message'>click hear to send a auto fill address and body of a mail</a>
Thanks & Regards
Sanwar
modified 7-Sep-12 7:39am.
|
|
|
|
|
Use this code outside the body tag ............
Thanks & Regards
Sanwar
|
|
|
|
|
Use these name spaces and above code
using System.Security.Cryptography;
using System.Text;
using System.IO;
private const string ENCRYPTION_KEY = "key";
private readonly static byte[] SALT = Encoding.ASCII.GetBytes(ENCRYPTION_KEY.Length.ToString());
public static string Encrypt(string inputText)
{
RijndaelManaged rijndaelCipher = new RijndaelManaged();
byte[] plainText = Encoding.Unicode.GetBytes(inputText);
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(ENCRYPTION_KEY, SALT);
using (ICryptoTransform encryptor = rijndaelCipher.CreateEncryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16)))
{
using (MemoryStream memoryStream = new MemoryStream())
{
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
{
cryptoStream.Write(plainText, 0, plainText.Length);
cryptoStream.FlushFinalBlock();
return Convert.ToBase64String(memoryStream.ToArray());
}
}
}
}
public static string Decrypt(string inputText)
{
RijndaelManaged rijndaelCipher = new RijndaelManaged();
byte[] encryptedData = Convert.FromBase64String(inputText);
PasswordDeriveBytes secretKey = new PasswordDeriveBytes(ENCRYPTION_KEY, SALT);
using (ICryptoTransform decryptor = rijndaelCipher.CreateDecryptor(secretKey.GetBytes(32), secretKey.GetBytes(16)))
{
using (MemoryStream memoryStream = new MemoryStream(encryptedData))
{
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
{
byte[] plainText = new byte[encryptedData.Length];
int decryptedCount = cryptoStream.Read(plainText, 0, plainText.Length);
return Encoding.Unicode.GetString(plainText, 0, decryptedCount);
}
}
}
}
Thanks & Regards
Sanwar
|
|
|
|
|
Select '130'+'120'+1 --> Ans-130121 In this query the first plus sign between two strings indicates the concatenation and the second plus sign between second string and digit 1 indicates the addition the string will converted to digit at the time of addition.
SELECT DATEADD(s,0,0) --> Ans- 1900-01-01 00:00:00.000 DATEADD function adds zero seconds to default datetime 1900-01-01 00:00:00.000
SELECT ISNULL(1,2) --> Ans 1 ISNULL checks the first argument, if it is NULL then it returns the second argument. Else it returns first argument.
-- Ques Table A has 10 rows including 3 Null rows. Table B has 7 rows including 3 Null rows.
Select Count(*) from [Table A]Select Count(Column Name) from [Table B]
--> Ans- Table A will return 10 rows and Table B will return 4 rows (Because when we use count(*),it will return total number of rows in a table including null rows. But count(column Name) will only return NOT NULL rows.)
-- Ques-- What is the maximum number of columns that can participate in a TABLE's primary key? --> 16
-- Quest The default varchar, nvarchar datatype length is 30 NOTE->when we use it with the cast option ,Using as like
select CAST('aaaaaaaaaaaaaaaaaaaaabbddddddddddddFF' as nvarchar)
select CONVERT(nvarchar ,'aaaaaaaaaaaaaaaaaaaaabbddddddddddddFF')
-- if use this type then it will take only Default strating 1 value
declare @Type nvarchar
set @Type='aaaaaaaaaaaaaaaaaaaaabbddddddddddddFF'
print @Type
-- In SQL Server 2012, how many index types are available? Answer-->10,12
-- 1. A Temporary Table can have primary keys and indexes defined -Answer-->True
--2. A Table Variable can have primary keys and indexes defined -Answer-->True
--How many maximum processor cores does SQL Server 2008 R2 Datacenter edition support? -Answer-->256
Thanks & Regards
Sanwar
|
|
|
|
|
1st way
Select * from ( SELECT ROW_NUMBER() OVER (
ORDER BY ProductID) AS RowNumber ,ProductID ,
Product,Title,Colour,Fabric,Weight,
YourPrice,SalePrice,IsDeleted ,IsUploaded,IsUpdated
FROM RSS_tblProductsMaster)xx inner join
( select MAX( aa.RowNumber)as RowNumber from (
SELECT ROW_NUMBER() OVER (
ORDER BY ProductID) AS RowNumber ,ProductID
FROM RSS_tblProductsMaster )
aa group by aa.ProductID) YY on xx.RowNumber=YY.RowNumber
2nd way
IF OBJECT_ID('tempdb..#RSS_tblProductsMaster') IS NOT NULL
BEGIN
drop table #RSS_tblProductsMaster
END
SELECT ROW_NUMBER() OVER (
ORDER BY ProductID) AS 'RowNumber',ProductID ,
Product,Title,Colour,Fabric,Weight,
YourPrice,SalePrice,IsDeleted ,IsUploaded,IsUpdated
into #RSS_tblProductsMaster FROM RSS_tblProductsMaster
delete
FROM #RSS_tblProductsMaster
WHERE RowNumber NOT IN
(
SELECT MAX(RowNumber)
FROM #RSS_tblProductsMaster
GROUP BY ProductID)
select * from #RSS_tblProductsMaster
3rd way
My table is
Col1 Col2 Col3
1 2 3
1 4 5
2 5 6
Require RESULT of This table
Col1 Col2 Col3
1 2 3
2 5 6
select * from duplicate
truncate table duplicate2
declare @col1 int=0,@col2 int=0,@col3 int=0
declare mycur cursor for select col1 from duplicate
OPEN mycur
FETCH NEXT FROM mycur INTO @col1
WHILE @@FETCH_STATUS = 0
BEGIN
if not exists (select 1 from duplicate2 where col1=@col1)
Begin
select @col2=col2,@col3=col3 from duplicate where col1=@col1
insert into duplicate2(col1,col2,col3) values(@col1,@col2,@col3)
End
FETCH NEXT FROM mycur INTO @col1
end
close mycur
deallocate mycur
select * from duplicate2
Thanks & Regards
Sanwar
|
|
|
|
|
SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%Entertablename%'
Thanks & Regards
Sanwar
|
|
|
|
|
Main difference is each class base class is Object class, and object class has few methods , .ToString() is one of them , you can write overload and override .
So when you call object.ToString() its mean it will call that objects ToString
there for if object is null then it will throw an exception Object is not set to an instance of an object.
When you call Convert.ToString method, Convert is a static class where we pass our object and get the out put in that method its check where the object is null or no if not the call that objects ToString method other wise return null.
This is the main difference.
object objec = null;
string objValue1 = objec .ToString();
string objValue2 = Convert.ToString(objec);
Thanks & Regards
Sanwar
|
|
|
|
|
DECLARE @position int, @string varchar(100), @FirstStrVal int
DECLARE @position1 int, @string1 varchar(100), @SecondStrVal int
set @FirstStrVal=0
set @SecondStrVal=0
SET @position = 1
SET @position1 = 1
SET @string = rtrim(ltrim ('AAAAAA'))
SET @string1 = rtrim(ltrim ('BBBBBB'))
WHILE @position <= DATALENGTH(@string)
BEGIN
set @FirstStrVal=@FirstStrVal+( SELECT ASCII(SUBSTRING(@string, @position, 1)))
SET @position = @position + 1
END
WHILE @position1 <= DATALENGTH(@string1)
BEGIN
set @SecondStrVal=@SecondStrVal+( SELECT ASCII(SUBSTRING(@string1, @position1, 1)))
SET @position1 = @position1 + 1
END
if(@SecondStrVal>@FirstStrVal)
begin
print 'Second String > First String'
end
else
begin
print 'First String > Second String'
end
|
|
|
|
|
declare @house nvarchar(200)
declare @city nvarchar(200)
declare @state nvarchar(200)
set @house='50';
set @city='Himaat nagar';
set @state='Delhi';
select case when @house !='' then @house else '' end + (case when @city !='' then case when @house!='' then ' , '+@city else @city end else '' end) +
(case when @state !='' then case when @city!='' then ' , '+@state else @state end else ''end)
|
|
|
|
|