toolbar updated

I updated my toolbar with development related links and rss feeds.

Take a look at the open source and references & tutorials categories.

It´s free, it´s private and it´s secure!
The toolbar works with internet explorer and firefox.
..:: to get it, download now my toolbar here ::..

Your suggestions are appreciated!

Advertisements

a complete sample: detailview callbacks editing and paging

Detailview.aspx:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”DetailView.aspx.cs” Inherits=”testweb2.DDD” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml&#8221; >
<head runat=”server”>
<title>Detailsview with callback</title>

<script language=”javascript”>

function Pager(page)
{
<%= ClientScript.GetCallbackEventReference(this, “page”, “ShowResult”, null) %>;
}

function ShowResult(val, ctx)
{
document.getElementById(‘dv’).innerHTML = val;
}
</script>

<script type=”text/javascript”>
function CallServer(str)
{
var product = str;
<%= ClientScript.GetCallbackEventReference(this, “product”, “ReceiveServerData”,null)%>;
}

function ReceiveServerData(rValue)
{
document.getElementById(‘dv’).innerHTML = rValue;
}

</script>
</head>
<body>
<form id=”form1″ runat=”server”>
<div id=”dv”>
<asp:DetailsView ID=”DetailsView1″ runat=”server” Height=”50px” Width=”288px” BackColor=”White” BorderColor=”#E7E7FF” BorderStyle=”None” BorderWidth=”1px” CellPadding=”3″ DataSourceID=”SqlDataSource1″ AllowPaging=”True” AutoGenerateRows=”False” DataKeyNames=”countryid” OnDataBound=”DetailsView1_DataBound”>
<FooterStyle BackColor=”#B5C7DE” ForeColor=”#4A3C8C” />
<RowStyle BackColor=”#E7E7FF” ForeColor=”#4A3C8C” />
<PagerStyle BackColor=”#E7E7FF” ForeColor=”#4A3C8C” HorizontalAlign=”Right” />
<HeaderStyle BackColor=”#4A3C8C” Font-Bold=”True” ForeColor=”#F7F7F7″ />
<EditRowStyle BackColor=”#738A9C” Font-Bold=”True” ForeColor=”#F7F7F7″ />
<AlternatingRowStyle BackColor=”#F7F7F7″ />
<Fields>
<asp:BoundField DataField=”countryid” HeaderText=”countryid” InsertVisible=”False”
ReadOnly=”True” SortExpression=”countryid” />
<asp:BoundField DataField=”countryname” HeaderText=”countryname” SortExpression=”countryname” />
<asp:TemplateField ShowHeader=”False”>
<EditItemTemplate>
<asp:LinkButton ID=”LinkButtonUpdate” runat=”server” CausesValidation=”True” CommandName=”Update”
Text=”Update”></asp:LinkButton>
<asp:LinkButton ID=”LinkButtonCancel” runat=”server” CausesValidation=”False” CommandName=”Cancel”
Text=”Cancel”></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<asp:LinkButton ID=”LinkButtonInsert” runat=”server” CausesValidation=”True” CommandName=”Insert”
Text=”Insert”></asp:LinkButton>
<asp:LinkButton ID=”LinkButtonCancel” runat=”server” CausesValidation=”False” CommandName=”Cancel”
Text=”Cancel”></asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
<asp:LinkButton ID=”LinkButtonEdit” runat=”server” CausesValidation=”False” CommandName=”Edit”
Text=”Edit”></asp:LinkButton>
<asp:LinkButton ID=”LinkButtonNew” runat=”server” CausesValidation=”False” CommandName=”New”
Text=”New”></asp:LinkButton>
<asp:LinkButton ID=”LinkButtonDelete” runat=”server” CausesValidation=”False” CommandName=”Delete”
Text=”Delete”></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>

</div>

<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
ConnectionString=”<%$ ConnectionStrings:tttConnectionString %>”
DeleteCommand=”DELETE FROM [country] WHERE [countryid] = @original_countryid AND [countryname] = @original_countryname”
InsertCommand=”INSERT INTO [country] ([countryname]) VALUES (@countryname)”
SelectCommand=”SELECT * FROM [country]”
UpdateCommand=”UPDATE [country] SET [countryname] = @countryname WHERE [countryid] = @original_countryid AND [countryname] = @original_countryname” OldValuesParameterFormatString=”original_{0}” ProviderName=”System.Data.SqlClient”>
<DeleteParameters>
<asp:ControlParameter ControlID=”DetailsView1″ Name=”original_countryid” PropertyName=”SelectedValue”
Type=”Int32″ />
<asp:ControlParameter ControlID=”DetailsView1″ Name=”original_countryname” PropertyName=”SelectedValue”
Type=”String” />
</DeleteParameters>
<UpdateParameters>
<asp:ControlParameter ControlID=”DetailsView1″ Name=”countryname” PropertyName=”SelectedValue”
Type=”String” />
<asp:ControlParameter ControlID=”DetailsView1″ Name=”original_countryid” PropertyName=”SelectedValue”
Type=”Int32″ />
<asp:ControlParameter ControlID=”DetailsView1″ Name=”original_countryname” PropertyName=”SelectedValue”
Type=”String” />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID=”DetailsView1″ Name=”countryname” PropertyName=”SelectedValue”
Type=”String” />
</InsertParameters>
</asp:SqlDataSource>

</form>
</body>
</html>
CodeBehind:DetailView.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

using System.Data.SqlClient;
using System.Data.Common;

namespace testweb2
{
public partial class DDD : System.Web.UI.Page, ICallbackEventHandler
{

#region ICallbackEventHandler
public string GetCallbackResult()
{
StringWriter sr = new StringWriter();
HtmlTextWriter htm = new HtmlTextWriter(sr);
this.DetailsView1.RenderControl(htm);
htm.Close();
sr.Close();
return sr.ToString();

}

public void RaiseCallbackEvent(string eventArgument)
{
string[] command = eventArgument.Split(new char[] { ‘,’ });
string work = command[0];
if (work == “Edit”)
{
this.DetailsView1.ChangeMode(DetailsViewMode.Edit);
}

if (work == “Delete”)
{
this.DetailsView1.DeleteItem();
this.SqlDataSource1.Delete();
}
else if (work == “New”)
{
this.DetailsView1.ChangeMode(DetailsViewMode.Insert);
}
else if (work == “Insert”)
{
this.DetailsView1.InsertItem(true);
}
else if (work == “Update”)
{
this.DetailsView1.ChangeMode(DetailsViewMode.Edit);
this.DetailsView1.UpdateItem(true);
}
else
{
if (work.Split(new char[] { ‘|’ })[0] == “page”)
{
this.DetailsView1.PageIndex = int.Parse((work.Split(new char[] { ‘|’ })[1])) – 1;
}
}
this.DetailsView1.DataBind();
}

#endregion

protected void DetailsView1_DataBound(object sender, EventArgs e)
{

object my = this.DetailsView1;

foreach (TableRow row in this.DetailsView1.Rows)
{

LinkButton btnEdit = row.FindControl(“LinkButtonEdit”) as LinkButton;
if (btnEdit != null) btnEdit.Attributes.Add(“onclick”, “CallServer(‘Edit’); return false;”);

LinkButton btnNew = row.FindControl(“LinkButtonNew”) as LinkButton;
if (btnNew != null) btnNew.Attributes.Add(“onclick”, “CallServer(‘New’); return false;”);

LinkButton btnDelete = row.FindControl(“LinkButtonDelete”) as LinkButton;
if (btnDelete != null) btnDelete.Attributes.Add(“onclick”, “CallServer(‘Delete’); return false;”);

LinkButton btnInsert = row.FindControl(“LinkButtonInsert”) as LinkButton;
if (btnInsert != null) btnInsert.Attributes.Add(“onclick”, “CallServer(‘Insert’); return false;”);

LinkButton btnUpdate = row.FindControl(“LinkButtonUpdate”) as LinkButton;
if (btnUpdate != null) btnUpdate.Attributes.Add(“onclick”, “CallServer(‘Update’); return false;”);

LinkButton btnCancel = row.FindControl(“LinkButtonCancel”) as LinkButton;
if (btnCancel != null) btnCancel.Attributes.Add(“onclick”, “CallServer(‘Cancel’); return false;”);

}

if (this.DetailsView1.BottomPagerRow.Controls[0].HasControls())
{
TableRow myrow = (TableRow)this.DetailsView1.BottomPagerRow.Controls[0].Controls[0].Controls[0];

foreach (TableCell cell in myrow.Cells)
{
if (cell.HasControls())
{
LinkButton button = cell.Controls[0] as LinkButton;
if (button != null)
{
button.Attributes.Add(“onclick”, “Pager(‘page|” + button.Text + “‘); return false;”);
}
}
}
}
}
}
}

a complete sample: gridview callbacks sorting, paging and editing

gridview.aspx:

<%@ Page Language=”C#” AutoEventWireup=”false” EnableEventValidation=”true” CodeFile=”GridView.aspx.cs”
Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head id=”Head1″ runat=”server”>
<title>Untitled Page</title>

<script language=”javascript”>

function SortGrid(column)
{
var sort=””;
sort = document.getElementById(‘HFsort’).value;
if ( sort==”asc”) document.getElementById(‘HFsort’).value = “desc”; else document.getElementById(‘HFsort’).value =”asc”;

column=column+”|”+document.getElementById(‘HFsort’).value ;

<%= ClientScript.GetCallbackEventReference(this, “column”, “ShowResult”, null) %>;
}

function Pager(page)
{
<%= ClientScript.GetCallbackEventReference(this, “page”, “ShowResult”, null) %>;
}

function ShowResult(val, ctx)
{
document.getElementById(‘gv’).innerHTML = val;
}
</script>

<script type=”text/javascript”>
function CallServer(str)
{
var product = str;
<%= ClientScript.GetCallbackEventReference(this, “product”, “ReceiveServerData”,null)%>;
}

function ReceiveServerData(rValue)
{
document.getElementById(‘gv’).innerHTML = rValue;
}

</script>

</head>
<body>
<form id=”form1″ runat=”server”>
<div id=’gv’>
<asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False” DataSourceID=”SqlDataSource1″
OnRowDataBound=”GridView1_RowDataBound” OnRowUpdating=”GridView1_RowUpdating”
Style=”font-family: Arial” BackColor=”White” BorderColor=”#E7E7FF” BorderStyle=”None”
BorderWidth=”1px” CellPadding=”3″ GridLines=”Horizontal” AllowPaging=”True” AllowSorting=”True”
EnableViewState=”False” OnRowCreated=”GridView1_RowCreated” DataKeyNames=”countryid”
PageSize=”3″>
<FooterStyle BackColor=”#B5C7DE” ForeColor=”#4A3C8C” />
<RowStyle BackColor=”#E7E7FF” ForeColor=”#4A3C8C” />
<Columns>
<asp:TemplateField ShowHeader=”False”>
<EditItemTemplate>
<asp:LinkButton ID=”LinkButtonUpdate” runat=”server” CausesValidation=”True” CommandName=”Update”
Text=”update”></asp:LinkButton>
<asp:LinkButton ID=”LinkButtonCancel” runat=”server” CausesValidation=”False” CommandName=”Cancel”
Text=”cancel”></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID=”LinkButtonEdit” runat=”server” CausesValidation=”False” CommandName=”Edit”
Text=”edit”></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=”countryid” HeaderText=”countryid” InsertVisible=”False”
ReadOnly=”True” SortExpression=”countryid” />
<asp:BoundField DataField=”countryname” HeaderText=”countryname” SortExpression=”countryname” />
</Columns>
<PagerStyle BackColor=”#E7E7FF” ForeColor=”#4A3C8C” HorizontalAlign=”Right” />
<SelectedRowStyle BackColor=”#738A9C” Font-Bold=”True” ForeColor=”#F7F7F7″ />
<HeaderStyle BackColor=”#4A3C8C” Font-Bold=”True” ForeColor=”#F7F7F7″ />
<AlternatingRowStyle BackColor=”#F7F7F7″ />
</asp:GridView>
</div>
<asp:HiddenField ID=”HFsort” runat=”server” Value=”asc” />
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” ConnectionString=”<%$ ConnectionStrings:tttConnectionString %>”
DeleteCommand=”DELETE FROM [country] WHERE [countryid] = @original_countryid AND [countryname] = @original_countryname”
InsertCommand=”INSERT INTO [country] ([countryname]) VALUES (@countryname)” SelectCommand=”SELECT * FROM [country]”
UpdateCommand=”UPDATE [country] SET [countryname] = @countryname WHERE [countryid] = @original_countryid AND [countryname] = @original_countryname”
ConflictDetection=”CompareAllValues” OldValuesParameterFormatString=”original_{0}”>
<DeleteParameters>
<asp:Parameter Name=”original_countryid” Type=”Int32″ />
<asp:Parameter Name=”original_countryname” Type=”String” />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name=”countryname” Type=”String” />
<asp:Parameter Name=”original_countryid” Type=”Int32″ />
<asp:Parameter Name=”original_countryname” Type=”String” />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name=”countryname” Type=”String” />
</InsertParameters>
</asp:SqlDataSource>
</form>

codebehind: gridview.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;

public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{

protected void Page_Load(object sender, EventArgs e)
{
}

#region ICallbackEventHandler

public string GetCallbackResult()
{
StringWriter sr = new StringWriter();
HtmlTextWriter htm = new HtmlTextWriter(sr);
this.GridView1.RenderControl(htm);
htm.Close();
sr.Close();
return sr.ToString();
}

public void RaiseCallbackEvent(string eventArgument)
{

string[] command = eventArgument.Split(new char[] { ‘,’ });
string work = command[0];
if (work == “Edit”)
{
this.GridView1.EditIndex = Convert.ToInt32(command[1]);

}
else if (work == “Update”)
{

}
else if (work == “Cancel”)
{

}
else
{
if (work.Split(new char[] { ‘|’ })[0] == “page”)
{
GridView1.PageIndex = int.Parse((work.Split(new char[] { ‘|’ })[1])) -1;
}
else
{
if (work.Split(new char[] { ‘|’ })[1] == “asc”)
{
this.GridView1.Sort(work.Split(new char[] { ‘|’ })[0], SortDirection.Descending);
}
else
{
this.GridView1.Sort(work.Split(new char[] { ‘|’ })[0], SortDirection.Ascending);
}
}
}
this.GridView1.DataBind();

}

#endregion

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row != null && e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell cell in e.Row.Cells)
{
if (cell.HasControls())
{
LinkButton button = cell.Controls[0] as LinkButton;
if (button != null)
{
if (GridView1.SortExpression == button.CommandArgument)
{
Image image = new Image();
if (GridView1.SortDirection == SortDirection.Ascending)
image.ImageUrl = “arrow_down.gif”;
else
image.ImageUrl = “arrow_up.gif”;
cell.Controls.Add(image);
}
}
}
}
}
}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell cell in e.Row.Cells)
{
if (cell.HasControls())
{
LinkButton button = cell.Controls[0] as LinkButton;
if (button != null)
{
button.Attributes.Add(“onclick”, “SortGrid(‘” + button.Text + “‘); return false;”);
}
}
}
}

else if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton btnEdit = e.Row.FindControl(“LinkButtonEdit”) as LinkButton;
if (btnEdit != null) btnEdit.Attributes.Add(“onclick”, “CallServer(‘Edit,” + e.Row.RowIndex + “‘); return false;”);
LinkButton btnUpdate = e.Row.FindControl(“LinkButtonUpdate”) as LinkButton;
if (btnUpdate != null) btnUpdate.Attributes.Add(“onclick”, “CallServer(‘Update,” + e.Row.RowIndex + “‘); return false;”);
LinkButton btnCancel = e.Row.FindControl(“LinkButtonCancel”) as LinkButton;
if (btnCancel != null) btnCancel.Attributes.Add(“onclick”, “CallServer(‘Cancel,” + e.Row.RowIndex + “‘); return false;”);

}
else if (e.Row.RowType == DataControlRowType.Pager)
{

TableRow myrow = (TableRow)e.Row.Cells[0].Controls[0].Controls[0];

foreach (TableCell cell in myrow.Cells)
{
if (cell.HasControls())
{
LinkButton button = cell.Controls[0] as LinkButton;
if (button != null)
{
button.Attributes.Add(“onclick”, “Pager(‘page|” + button.Text + “‘); return false;”);
}
}
}
}
}
}

..:: Whereever you go, stay in touch. Download toolbar now! It´s free, private and secure. ::..

A sample how to track page usage

The function tracker will be called when browser window is closed.

logpage.aspx
<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”logpage.aspx.cs” Inherits=”logpage” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml&#8221; >
<head runat=”server”>
<title>Pagetracking Sample</title>

<script type=”text/javascript”>

function CallServer(str)
{
var product = str;
<%= ClientScript.GetCallbackEventReference(this, “product”, “ReceiveServerData”,null)%>;
}

function ReceiveServerData(rValue)
{
document.getElementById(‘_div’).innerHTML = rValue;
}

</script>
</head>

<body onunload =”CallServer(‘close’);return false;”>
<form id=”form1″ runat=”server”>
<div id=”_div”>

</div>
</form>
</body>
</html>

codebehind:logpage.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.IO;

public partial class logpage : System.Web.UI.Page, ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager cs = Page.ClientScript;
string er = ClientScript.GetCallbackEventReference(this, “”, “null”, “null”, “null”, true);
string rb = “function CallServer(arg) {” + er + “;}”;
cs.RegisterClientScriptBlock(this.GetType(), “CallServer”, rb, true);
}

#region ICallbackEventHandler

public string GetCallbackResult()
{

return “”;
}

public void RaiseCallbackEvent(string eventArgument)
{
tracker();
}

#endregion

private void tracker()
{
StreamWriter s = new StreamWriter(“C:\\closehistory.txt”);
s.WriteLine(“close at:” + DateTime.Now.ToString());
s.Close();
}

}