Skip to main content

Posts

Showing posts from 2013

AJAX AUTOCOMPLETED

Code for AJAX AUTOCOMPLETED ----------------.aspx-------------- <asp:TextBox ID="txt_Narration" runat="server" Width="200px" OnTextChanged="txt_Narration_TextChanged" AutoPostBack="true"> </asp:TextBox>&nbsp; <div id="div_NARRATION"> </div> <cc1:AutoCompleteExtender runat="server" ID="AutoComplete_NARRATION" BehaviorID="autoCompleteNARRATION" TargetControlID="txt_Narration" ServicePath="~/webservices/CommonWebService.asmx" ServiceMethod="Get_Narration" MinimumPrefixLength="1" CompletionInterval="10" EnableCaching="true" CompletionSetCount="12" CompletionListCssClass="AutoExtender" CompletionListItemCssClass="AutoExtenderList" CompletionListHighlightedItemCssClass="AutoExtenderHighlight" CompletionListElementID="div_NARRATION"> </cc1:AutoCompleteExtende...

JAVASCRIPT ALERT ON CLASS PAGE

----------------.aspx-------------- JAVASCRIPT FUNCTION function alertClick(Details) { alert(Details) return false; } .CS     string alert = "Enter Atleast One Debit Type and One Credit Type Ledger"; RegisterClientScriptBlock("gridcount", "<script Language='javascript'>window.onload = function(){return alertClick('" + alert + "');}</script>"); return;  ---------------- OR protected void Page_Load(object sender, EventArgs e) {   string message = "Hello! Mudassar.";   System.Text.StringBuilder sb = new System.Text.StringBuilder();   sb.Append("<script type = 'text/javascript'>");   sb.Append("window.onload=function(){");   sb.Append("alert('");   sb.Append(message);   sb.Append("')};");   sb.Append("</script>");   ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); }  

Code for AJAX TEXTCHANGE WEBSERVICE CALL

----------------.aspx--------------    <script language="javascript" type="text/javascript">             function CallParametersPageMethod()     {        Branch_Abrv = document.getElementById('txt_search').value;        CommonWebService.Mai_Login_Branch(Branch_Abrv,onSucceeded,onFailed); // CommonWebService ? WEBSERVICE NAME // Mai_Login_Branch ? METHOD NAME FROM WEBSERVICE     }     function onSucceeded(result,userContext,methodName)     {         if(result!="")         {           document.getElementById('txt_search').value= result;         }        }     function onFailed(error,userContext,methodName)  ...

AJAX TAB CONTROL

<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <cc1:tabcontainer id="TabContainer1" runat="server" activetabindex="0" style="z-index: 18; left: 0px; top: 0px" width="100%" cssclass="ajax__myTab" backcolor="#FFFBD6"> <%--ledger details--%> <cc1:TabPanel ID="Tab_Ledger_Details" runat="server" HeaderText="Voucher Details" Width="100%" Style="text-align: left" BackColor="#FFFBD6"> <ContentTemplate> </ContentTemplate> </cc1:TabPanel> <%--vourcher details complet--%> <%--Bill and cost tab start--%> <cc1:TabPanel ID="Tab_Bill_Cost" runat="server" HeaderText="Bill and Cost Details" Width="100%" BackColor="#FFFBD6"> <ContentTemplate> </ContentTemplate> </cc1:TabPanel> <%--Bill and co...

Function that Splits string in SQL Server / Table Valued Function

CREATE FUNCTION [dbo] . [SplitString] ( @SplitStr nvarchar ( 1000 ), @SplitChar nvarchar ( 5 ) ) RETURNS @RtnValue table ( Data nvarchar ( 50 ) ) AS BEGIN Declare @Count int Set @Count = 1 While ( Charindex ( @SplitChar , @SplitStr )> 0 ) Begin Insert Into @RtnValue ( Data ) Select Data = ltrim ( rtrim ( Substring ( @SplitStr , 1 , Charindex ( @SplitChar , @SplitStr )- 1 ))) Set @SplitStr = Substring ( @SplitStr , Charindex ( @SplitChar , @SplitStr )+ 1 , len ( @SplitStr )) Set @Count = @Count + 1 End Insert Into @RtnValue ( Data ) Select Data = ltrim ( rtrim ( @SplitStr )) Return END To Execute above Function use the statement as follows select * from dbo . SplitString ( ',abc,defg,hij,klm,nopq,Test,123,' , ',' )

sql inda all country in database

CREATE TABLE country ( id int NOT NULL , country_code varchar(5) NOT NULL default '', country_name varchar(100) NOT NULL default '', ) -- INSERT INTO country VALUES (1, 'US', 'United States'); INSERT INTO country VALUES (2, 'CA', 'Canada'); INSERT INTO country VALUES (3, 'AF', 'Afghanistan'); INSERT INTO country VALUES (4, 'AL', 'Albania'); INSERT INTO country VALUES (5, 'DZ', 'Algeria'); INSERT INTO country VALUES (6, 'DS', 'American Samoa'); INSERT INTO country VALUES (7, 'AD', 'Andorra'); INSERT INTO country VALUES (8, 'AO', 'Angola'); INSERT INTO country VALUES (9, 'AI', 'Anguilla'); INSERT INTO country VALUES (10, 'AQ', 'Antarctica'); INSERT INTO country VALUES (11, 'AG', 'Antigua and/or Barbuda'); INSERT INTO country VALUES (12, 'AR', 'Argentina'); INSERT INTO country VALUES ...

SQL NEW INSERT STORE PROCEDURE DYNAMICALLY

IF EXISTS (         SELECT *         FROM dbo.sysobjects         WHERE id = object_id(N'[dbo].[test_create_procedure]')             AND OBJECTPROPERTY(id, N'IsProcedure') = 1         )     DROP PROCEDURE [dbo].[test_create_procedure] GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS OFF GO ALTER PROCEDURE create_procedure @table VARCHAR(200),     @DeveloperName VARCHAR(200),     @Createtable VARCHAR(20)     --create_procedure 'Products','VISHAL','Products' AS SET NOCOUNT ON DECLARE @testTable VARCHAR(8000) DECLARE @testTable2 VARCHAR(8000) DECLARE @testTable3 VARCHAR(8000) DECLARE @opration VARCHAR(8000) DECLARE @testTable_UPDATE VARCHAR(8000) DECLARE @final VARCHAR(8000) DECLARE @OP VARCHAR(100) SET @testTable = '' SET @testTable2 = '' SET @final = '' SET @testTable3 =...

DYNAMIC SQL INSERT STATEMENT

create table #tmp ( SQLText varchar(8000) ) create table #tmp2 ( Id int identity, SQLText varchar(8000) ) set nocount on delete #tmp delete #tmp2 declare @vsSQL varchar(8000), @vsCols varchar(8000), @vsTableName varchar(40) declare csrTables cursor for select name from sysobjects where type in ('u') and name in ('Customers') order by name open csrTables fetch next from csrTables into @vsTableName while (@@fetch_status = 0) begin select @vsSQL = '', @vsCols = '' select @vsSQL = @vsSQL + CASE when sc.type in (39,47,61,111) then '''''''''+' + 'isnull(rtrim(replace('+ sc.name + ','''''''','''''''''''')),'''')' + '+'''''',''+' when sc.type = 35 then '''''''''+...

datatable group by

private DataTable GetGroupedBy(DataTable dt, string columnNamesInDt, string groupByColumnNames, string typeOfCalculation) { //Return its own if the column names are empty if (columnNamesInDt == string.Empty || groupByColumnNames == string.Empty) { return dt; } //Once the columns are added find the distinct rows and group it bu the numbet DataTable _dt = dt.DefaultView.ToTable(true, groupByColumnNames); //The column names in data table string[] _columnNamesInDt = columnNamesInDt.Split(','); for (int i = 0; i < _columnNamesInDt.Length; i = i + 1) { if (_columnNamesInDt[i] != groupByColumnNames) { _dt.Columns.Add(_columnNamesInDt[i]); } } //Gets the collection and send it back for (int i = 0; i < _dt.Rows.Count; i = i + 1) { for (int j = 0; j < _columnNamesInDt.Length; j = j + 1) { if (_columnNamesInDt[j] != groupByColumnNames) { _dt.Rows[i][j] = dt.Compute(typeOfCalculation + "(" + _columnNamesInDt[j] + ")", groupByColumnName...

Building a Database Driven Hierarchical Menu using ASP.NET

Download AspSooperFish

ASP.NET DATE FORMAT CUSTOME

string SSS = DateTime.Now.ToString("dddd, d MMMM, yyyy", CultureInfo.CreateSpecificCulture("en-US")); DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15); Console.WriteLine(date1.ToString( "ddd d MMM" , CultureInfo.CreateSpecificCulture( "en-US" ))); // Displays Fri 29 Aug Console.WriteLine(date1.ToString( "ddd d MMM" , CultureInfo.CreateSpecificCulture( "fr-FR" ))); // Displays ven. 29 août      DateTime date1 = new DateTime(2008, 8, 29, 19, 27, 15, 18); CultureInfo ci = CultureInfo.InvariantCulture; Console.WriteLine(date1.ToString( "hh:mm:ss.f" , ci)); // Displays 07:27:15.0 Console.WriteLine(date1.ToString( "hh:mm:ss.F" , ci)); // Displays 07:27:15 Console.WriteLine(date1.ToString( "hh:mm:ss.ff" , ci)); // Displays 07:27:15.01 Console.WriteLine(date1.ToString( "hh:mm:ss.FF" , ci)); // Displays 07:27:15.01 Console.WriteLine(date1....

SQL PARENT CHILD TREE STRUCTURE

-- DECLARE DECLARE @Company AS TABLE(EmpID INT, ParentID INT, PersonName VARCHAR(100)); -- Insert Temp Records INSERT INTO @Company(EmpID, ParentID, PersonName) VALUES(1 , NULL , 'Maulik Dhorajia')     , (2 , NULL , 'Bhavesh Gohel')     , (3 , NULL , 'Dinesh Padhiyar')     , (4 , 2 , 'Vijay Kumar')     , (5 , 1 , 'Jitendra Makwana')     , (6 , 4 , 'Jayesh Dhobi')     , (7 , 1 , 'Shivpalsinh Jhala')     , (8 , 5 , 'Amit Patel')     , (9 , 3 , 'Abidali Suthar') -- Default data SELECT * FROM @Company; -- Incorrect result which we usually find on Internet ;WITH CTECompany AS (     SELECT EmpID, ParentID, PersonName , 0 AS HLevel     FROM @Company     WHERE ParentID IS NULL         UNION ALL         SELECT C.EmpID, C.ParentID, C.PersonName , (CTE.HLevel + 1) AS HLevel ...

Creating Mailing Labels in SQL Server Reporting Services

Most word processing applications (Word, WordPerfect, and so on) provide the capability to create a “mail merge” from which to generate mailing labels in different formats and layouts. Mailing labels are an automated way to generate the address labels for a large number of envelopes or parcels that need to be mailed. Reporting Services provides a few features that allow you to create mailing labels in different formats - the only thing you need to know are the exact dimensions of the label template you are targeting when printing. A common mailing label format is to use multiple columns (newspaper layout) in order to maximize the number of labels printed. This recipe shows you how to leverage Reporting Services’ multi-column layout features to create basic mailing labels, while explaining certain limitations in the rendering engine. Product Versions All versions (examples provided in Reporting Services 2008) What You’ll Need AdventureWorksDW2008...