Thursday, April 21, 2011

Some good Web Sites for learners


Stored Precedure Return Value (0) or (1) Example
===========



Master pages.
===========
http://www.asp.net/master-pages/tutorials/creating-a-site-wide-layout-using-master-pages-cs


Jquery Enables Drag and drop
http://docs.jquery.com/UI/Draggable#event-stop
http://jqueryui.com/demos/droppable/
http://docs.jquery.com/UI


Using JSON Store Data in Database
http://stephenwalther.com/blog/archive/2010/03/26/using-jquery-to-insert-a-new-database-record.aspx

Ajax 
http://samples.gaiaware.net/BasicControls/GridView/RichInlineEditing/
http://www.asp.net/ajaxlibrary/act_tutorials.ashx

Excellent site for JavaScript
http://www.dynamicdrive.com/dynamicindex10/

Tutorial about each control
http://www.aspxcode.net/how-to-using-webparts-asp-net.aspx?Controls=WebPartZone

Understanding ASP.NET Web Parts and

What is Personalization?

http://www.singingeels.com/Articles/Understanding_ASPNET_Web_Parts.aspx

asp.net TextBook
http://books.google.co.in/books?id=ZaKr2hH-2QAC&pg=PA1269&lpg=PA1269&dq=store+personalization+info+at+clientside+in+asp.net+webparts&source=bl&ots=PRDUGcMKOa&sig=u54Mg2YG5uVAznL4JIc3vkOYEjM&hl=en&ei=DXq5TaG1JIKurAf_x_HdBA&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBgQ6AEwAA#v=onepage&q&f=false

Adding Membership Functionality To SQL Server in ASP.NET

http://www.singingeels.com/Articles/Membership_Using_ASPNET_AJAX.aspx

ASP.Net Tutorial
http://www.beansoftware.com/ASP.NET-Tutorials/Globalisation-Multilingual-CultureInfo.aspx

CSS Corners
==============
http://cssround.com/#

Tuesday, April 19, 2011

Java Script

//Add New row in grid using Javascript
--------------------------------------------------

<script type="text/javascript">  
    function addRow() {
        var grd = document.getElementById('uclReceiptDetails1_GridView1');
        var tbod = grd.rows[0].parentNode;
        var newRow = grd.rows[grd.rows.length - 1].cloneNode(true);
        // newRow.clear();
        tbod.appendChild(newRow);     
    }
</script>



reference:http://www.w3schools.com/jsref/event_onmouseout.asp
Mouse over and Out Events
========================
<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.getElementById("b1").src ="b_blue.gif";
}
function mouseOut()
{
document.getElementById("b1").src ="b_pink.gif";
}
</script>
</head>


<body>
<a href="http://www.w3schools.com" target="_blank">
<img border="0" alt="Visit W3Schools!" src="b_pink.gif" id="b1" width="26" height="26" onmouseover="mouseOver()" onmouseout="mouseOut()" /></a>
</body>
</html>


How to Write Javascript in Code behind
---------------------------------------------
protected void cmdSave_Click(object sender, EventArgs e)
{
    if ( condition)
    {
 string script = "<SCRIPT LANGUAGE='JavaScript'> ";
 script += "Confirm()";
 script += </SCRIPT>";
 Page.RegisterClientScriptBlock("ClientScript", script);
    }
}
Reference:
-----------
http://forums.asp.net/t/994368.aspx/1?Call+javascript+from+the+code+behind

How to get Alert WIndow
----------------
http://madskristensen.net/post/JavaScript-AlertShow(e2809dmessagee2809d)-from-ASPNET-code-behind.aspx

Friday, April 15, 2011

Fileupload in ASP.Net

Dynamic Controls in asp.net 4.0

AJAX Tutorials

Creating a TransactionWCF Service in 4.0


Create a table testtable with columns
as
empno
ename
esal
then follow the steps

Createing Interface: IService.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together.
[ServiceContract]
public interface IService
{

[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
void UpdateData(int eno,string ename,decimal esal);
[OperationContract]
DataSet DisplayData(int eno);
[OperationContract]
DataSet fill();
[OperationContract]
DataSet UpdateGrid(int eno,string ename,decimal esal);
[OperationContract]
void DeleteRow(int eno);
[OperationContract]
DataSet DispayAll();

}


Implementing the interface: service.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
[ServiceBehavior(IncludeExceptionDetailInFaults=true)]
public class Service : IService
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ToString());
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();

[OperationBehavior(TransactionScopeRequired=true)]
public void UpdateData(int eno,string ename,decimal esal)
{
con.Close();
con.Open();
cmd = new SqlCommand("insert into testtable(empno,ename,esal) values("+eno+",'"+ename+"',"+esal+")",con);
cmd.ExecuteNonQuery();
con.Close();
}
public DataSet DisplayData(int eno)
{
con.Close();
con.Open();
da= new SqlDataAdapter("select * from testtable where empno="+eno+"",con);
da.Fill(ds, "x");
return ds;
}
public DataSet fill()
{
con.Close();
con.Open();
da = new SqlDataAdapter("select * from testtable ", con);
da.Fill(ds, "ys");
return ds;
}
public DataSet UpdateGrid(int eno,string ename,decimal esal)
{
con.Close();
con.Open();
da = new SqlDataAdapter("update testtable set ename='" + ename + "',esal=" + esal + " where empno=" + eno + "", con);
da.Fill(ds, "as");
return ds;
}
public void DeleteRow(int eno)
{
con.Close();
con.Open();
cmd = new SqlCommand("delete from testtable where empno=" + eno + "", con);
cmd.ExecuteNonQuery();
}
public DataSet DispayAll()
{
con.Close();
con.Open();
da = new SqlDataAdapter("select * from testtable",con);
da.Fill(ds);
return ds;
}
}





Grid view Control Using WCF Service At Client Side Code

REference :
http://www.aspdotnetcodes.com/ViewQuestion_283.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Transactions;
using System.Data;

public partial class Client : System.Web.UI.Page
{
ServiceReference2.ServiceClient sc2 = new ServiceReference2.ServiceClient();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillgrid();
}
}
protected void btninsert_Click(object sender, EventArgs e)
{
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))
{
try
{
//ServiceReference1.ServiceClient sc1 = new ServiceReference1.ServiceClient();
//sc1.UpdateData();
sc2.UpdateData(Convert.ToInt32(txtEmpNum.Text),txtEmpName.Text.ToString(),Convert.ToDecimal(txtEmpSal.Text));
Response.Write("Values Inserted.. Transaction is complete..");
ts.Complete();
}
catch (Exception exe)
{
ts.Dispose();
Response.Write(exe.Message);
}
}
}
protected void btnDisply_Click(object sender, EventArgs e)
{
try
{
DataSet ds = sc2.DisplayData(Convert.ToInt32(txtEmpNum.Text));
//GridView1.DataSource = ds;
//GridView1.DataBind();
}
catch (Exception exe)
{
Response.Write(exe.Message);
}
//GridView2.DataSource = ds;
//GridView2.DataBind();
}
public void fillgrid()
{
GridView2.DataSource=sc2.fill();
GridView2.DataBind();
}
protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView2.EditIndex = e.NewEditIndex;
fillgrid();
}
protected void GridView2_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView2.EditIndex = -1;
fillgrid();
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView2.PageIndex = e.NewPageIndex;
fillgrid();
}
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

TextBox empno = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtempno") as TextBox;
TextBox ename = GridView2.Rows[e.RowIndex].FindControl("txtename") as TextBox;
TextBox esal = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtesal") as TextBox;
sc2.UpdateGrid(Convert.ToInt32(empno.Text), ename.Text, Convert.ToDecimal(esal.Text));
GridView2.EditIndex = -1;
fillgrid();
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//int x=GridView2.DataKeys
//TextBox eno = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtempno") as TextBox;
string eno = GridView2.DataKeys[e.RowIndex].Value.ToString();
sc2.DeleteRow(Convert.ToInt32(eno));
fillgrid();
}
protected void btnDisplayAll_Click(object sender, EventArgs e)
{
fillgrid();
}
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
{
int i = GridView2.SelectedRow.RowIndex;
string s = GridView2.SelectedRow.Cells[0].Text;
string s1 = GridView2.SelectedValue.ToString();
Session["eid"] = s1;
string s2 = Session["eid"].ToString();
Response.Write("Selected Row Number is " + i.ToString() + " Name " + s1.ToString() + "Session values is " + s2);


/*
//string strScript = "<script>
strScript += " var newWindow = window.open('PopUp.aspx', '_blank','height=600, width=800,center=yes,status=no, resizable= yes, menubar=no, toolbar=no, location=no, scrollbars=no, status=no');</script>"";
strScript += "var newWindow = window.open('PopUp.aspx', '_blank','height=600, width=800,center=yes,status=no, resizable= yes, menubar=no, toolbar=no, location=no, scrollbars=no, status=no');";
strScript += "window.location='Client.aspx';";
strScript += "</script>";
Page.RegisterClientScriptBlock("strScript", strScript); */
Page.RegisterClientScriptBlock("strScript", "<script> var newWindow = window.open('PopUp.aspx', '_blank','height=600, width=800,center=yes,status=no, resizable= yes, menubar=no, toolbar=no, location=no, scrollbars=no, status=no');</script>");
}
}