Information about ASP.NET, C#, VB.NET,JQuery, AJAX, SQL Server, Java script,.NET tips and tricks, LINQ, OOPS Concept, DotNet Interview Questions
Saturday, December 22, 2012
How to Close Window Using Javascript
Friday, March 23, 2012
Bind Dropdown Using Javascript and Webservice
1) Add Webservice wsCountry.asmxusing System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Script.Services;
using System.Web.Services;
using Test;
///
/// Summary description for wsCountry
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class wsCountry : System.Web.Services.WebService
{
public wsCountry()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public List FindAllCountries()
{
List locations = new List();
string connectionString = ConfigurationManager.ConnectionStrings["TestDBConnectionString"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand())
{
command.Connection = connection;
command.CommandText = "SelectAllCountries";
command.CommandType = CommandType.StoredProcedure;
connection.Open();
using (SqlDataReader dataReader = command.ExecuteReader())
{
Location location;
if (dataReader != null)
while (dataReader.Read())
{
location = new Location();
location.CountryID = (int)dataReader["CountryID"];
location.CountryName = Convert.ToString(dataReader["CountryName"]);
locations.Add(location);
}
}
}
}
return locations;
}
}
namespace Test
{
[Serializable]
public class Location
{
public int CountryID
{ get; set; }
public string CountryName
{ get; set; }
}
}
2) Add ASPX Page and Call web service method.Add script managerAdd Service Reference in the script ManagerCall Web service on the page load and get result and add that result to Dropdown.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BindDropDown.aspx.cs" EnableEventValidation="false" Inherits="BindDropDown" %>
Bind Dropdown
Wednesday, September 2, 2009
Set Session variable in javascript function
How can I set session variables with JavaScript ?
#How can I set session variables with JavaScript
#Assigning Session variable from Javascript
#How do i set a session variable using javascript?
Tuesday, August 11, 2009
OPENING NEW WINDOWS
var newwindow;
function openwindow(url)
{
newwindow=window.open(url,'name','height=800,width=600');
if (window.focus) {newwindow.focus()}
}
Monday, May 25, 2009
How To Generate IFrame At Runtime Using Javascript
Thursday, May 14, 2009
How to Print Div Tag Using Javascript?
HTML FILE :
<script language="javascript">
function CallPrint( strid )
{
var prtContent = document.getElementById( strid );
var WinPrint = window.open('', '', 'left=0,top=0,width=900,height=600,toolbar=1,scrollbars=1,status=0');
WinPrint.document.write( prtContent.innerHTML );
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
script>
<div id="print_Grid">
This is Print
This is Print
This is Print
This is Print
This is Print
div>
Code FILE :
protected void Page_Load(object sender, EventArgs e)
{
btnPrint.Attributes.Add("onclick", "javascript:CallPrint('print_Grid')");
}
How To Use This Code?
1. Copy JavaScript into your HTML Page
2. Make a Div Tag Which data you want to print into that div tag
3. Add Print Button and call JavaScript Function
Wednesday, April 1, 2009
confirmation message on delete in a gridview
//Add delete msgbox to each row containing field
//information to identify the row
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// reference the Delete ImageButton
ImageButton ib = (ImageButton)e.Row.FindControl(“ibDelete”);
ib.Attributes.Add(“onclick”,“javascript:return ” +
DataBinder.Eval(e.Row.DataItem, ColomnName) + “?’);”);
}
}
OR
Add New Client Click property of button
return confirm(’Are you sure about deleting ”);
OR
Use Ajax Extender for confirmation box
<asp:TemplateField HeaderText=”Delete” >
<ItemStyle CssClass=”grid-column-buttons” />
<ItemTemplate>
<asp:ImageButton ID=”ibDelete” runat=”server”
CausesValidation=”False” CommandName=”Delete”
ImageUrl=”~/Images/icon-delete.gif” />
<ajaxToolkit:ConfirmButtonExtender ID=”ConfirmBtExt1″
runat=”server” TargetControlID=”ibDelete”
ConfirmText=’Are you sure about deleting this record?’ />
ItemTemplate>
asp:TemplateField>
ShareThis
Welcome
Here you can find some useful code and information about asp.net., c#, VB.net, SQL Server, Web Service, Web Designing etc