Geeks With Blogs


Microsoft MVP


Moderator at CodeASP.NET

Quiz Master

free counters
Free counters
Added on January 19,2012

Follow Me @vmsdurano

A bit About Me

The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.

Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer" February 2009 Entries
Search ListBox items using JavaScript
This example shows how to select ListItems in the ListBox based from the TextBox values using JavaScript. Here’s the code block below. <html xmlns=" > <head id="Head1" runat="server"> <title>Demo</title... </head> <script type="text/javascript" language="javascript"> function SearchList() { var l = document.getElementById('&l... ListBox1.ClientID %>'); var tb = document.getElementById('&l... TextBox1.ClientID %>'); if(tb.value ......

Posted On Wednesday, February 25, 2009 8:14 PM

Creating a Simple ShoutBox with MultiLine TextBox
Overview This demo explains how to create a simple ShoutBox using the ASP.NET MultiLine TextBox. A “ShoutBox” basically allow end users to post commentsin the page. To begin let’s create a WebUserControl and implement our ShoutBox there. Why UserControl? We used WebUserControl so that we can re-use and place the control anywhere in your page by simply dragging it to the WebForm. Step 1: Creating the Database In this demo, I presumed that you already have a basic background on how to create a simple ......

Posted On Tuesday, February 24, 2009 5:50 PM

Moving ListItems between Two ListBox – Server Side Approach
This example shows how to move items between two ListBox. Basically it allows you to add, remove and move multiple list items at a time. To start, let’s set up our GUI. Just for simplicity of this demo, I set up the web form like this: 1: <head runat="server"> 2: <title>Moving ListItems between two ListBox</title> 3: </head> 4: <body> 5: <form id="form1" runat="server"> 6: <div> 7: <table> 8: <tr> 9: <td ><asp:ListBox ID="ListBox1" runat="server" ......

Posted On Tuesday, February 24, 2009 5:41 PM

Adding Default Select Option in the DropDownList
This demo shows on how to add a default Select option in the DropDownList. I decided to write this sample demo because I always encounter this question at the ASP.NET forums. To make this work then you just need to set the property AppendDataBoundItems to TRUE in the DropDownList. Here’s an example for adding a Select option declaratively at the mark up. <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true"... <asp:ListItem Value="-1">Select</as... ......

Posted On Tuesday, February 24, 2009 5:37 PM

Binding DropDownList, ListBox and CheckBoxList Control the ADO.NET way.
This example shows how to bind DropDownList, ListBox and CheckBoxList control with data from database using the ADO.NET way. Note that in this demo, I’m using the Northwind database. Now let’s set up the connection string. STEP 1: Setting up the Connection string In your web.config file set up the connection string there as shown below: <connectionStrings> <add name="DBConnection" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirec... Integrated Security=True;User ......

Posted On Tuesday, February 24, 2009 5:31 PM

Tip/Trick: Highlighting GridView Rows on Mouseover
Here’s an example on how to highlight GridView rows on mousover at RowCreated or RowDataBound event of GridView by simply adding an attributes to the row. Here’s the code block: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { string onmouseoverStyle = " string onmouseoutStyle = " if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmou... onmouseoverStyle); e.Row.Attributes.Add("onmou... ......

Posted On Tuesday, February 24, 2009 5:22 PM

Adding ASPNETDB.mdf file to SQL Server 2005
By default ASPNETDB will be automatically created under App_data directory in your application if personalization is use for the first time.If you wanted to locate ASPNETDB file in your Own Database (SQL Sevrer 2005) then just simply do the following -Copy the ASPNETDB that is located at the App_data Folder in your Apps and paste it anywhere in your drives.. the after copying -Remove the ASPNETDB in your App_Data folder -Open SqlServer 2005 or Studio Management Express -Right Click on Database Folder ......

Posted On Monday, February 23, 2009 4:40 PM

GridView Multiple Delete with CheckBox and Confirm
This demo describes how to implement multiple delete in GridView using CheckBox control and display a confirmation message upon deletion. Assuming that we have this GridView column mark up below <Columns> <asp:TemplateField> <HeaderTemplate> <asp:Button ID="ButtonDelete" runat="server" Text="Delete" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="CustomerID" ......

Posted On Sunday, February 22, 2009 2:01 AM

Display Confirmation Message on GridView Deleting
This demo describes the different approach to display a confirmation message when deleting a row in GridView and pass the id of the item to the confirmation message. Confirmation means a user is asked first if he/she wanted to delete a record by choosing an option (OK and CANCEL). In this demo, we use the JavaScript confirm function for displaying the confirmation message. Now let’s create our JavaScript confirm function. To do this switch to ASPX source and add the following code block within the ......

Posted On Sunday, February 22, 2009 1:52 AM

GridView Insert, Edit, Update and Delete – The Ado.Net way
This demo is a continuation of my previous example “Binding GridView with Data”. If you are not familiar of binding the GridView the way then I would suggest looking at my previous example first before you proceed to this example. Basically, this demo describes the basic way to do INSERT, EDIT, UPDATE and DELETE data in ASPNET GridView Control using the ADO.NET way. STEP 1: Creating a DataBase Table In this demo, I presumed that you already have a basic background on how to create a simple ......

Posted On Sunday, February 22, 2009 1:34 AM

Binding GridView with Data - The ADO.NET way
This example demonstrates how to populate GridView with data from the database using the ADO.NET way. Before you proceed reading this example be sure that you know the basics of ADO.NET manipulation. If you are not familiar with ADO.NET then I would suggest you to refer at the following link below: ADO.NET Tutorial STEP 1: Setting up the Connection String - Open your Web.config file and set up your connection string like below: <connectionStrings> <add name="MyDBConnection" connectionString="Data ......

Posted On Thursday, February 19, 2009 9:35 PM

Implementing ASP.NET WebParts with Different Authentication modes
Just follow these tutorials below regarding how to implement WebParts in ASP.NET based on different Authentication mode. WEBPART with Windows Authentication WEBPART with Anonymous Users WEBPART with FORM Authentication Good Luck! Technorati Tags: ASP.NET,WebParts ......

Posted On Tuesday, February 17, 2009 6:01 PM

Accessing Controls in GridView TemplateFields on GridView Edit Mode
This example demonstrates how to access ASP.NET server controls that resides within the TemplateField Column of GridView on Edit Mode. In this example we are using the PreRender event of GridView instead of RowEditing event since we cannot directly access controls at RowEditing event of GridView. See below for example: protected void GridView1_PreRender(object sender, EventArgs e){ if (this.GridView1.EditIndex != -1){ Button b = GridView1.Rows[GridView1.Ed... as Button; ......

Posted On Tuesday, February 17, 2009 5:35 PM

Displaying Wait Message on Page Load in ASP.NET
This example simulates on how to display a loading message with gif image when the page loads in ASP.NET. <html xmlns=" ><head id="Head1" runat="server"> <title>Load Wait Message Demo</title></head... type="text/javascript" language="javascript"> if(document.getElementById){ // IE 5 and up, FF var upLevel = true; }else if(document.layers) { // Netscape 4 var ns4 = true; } elseif(document.all) { //IE 4 var ie4 = true; } function ......

Posted On Tuesday, February 17, 2009 5:18 PM

Display Contents of MultiLine TextBox to Label Control and Retain its Line Breaks
This example demonstrates how to print or display the contents of the MultiLine TextBox in a Label Control and retain its line breaks. Basically MultiLine Mode of TextBox uses Environment.NewLine to create a new line. So if you try to display the values of TextBox in a Label Control or print it on the page and retain its position then you can replace the Environment.NewLine with <BR> Tag since Label control doesn't recognized Environment.NewLine. Here's a sample demo below for your reference: ......

Posted On Tuesday, February 17, 2009 5:04 PM

Automatically Adjust the Hieght of the TextBox based on its Contents
This example shows how we are going to set the Height of the MultiLine TextBox automatically when the contents of the TextBox is larger than the size of the TextBox. First thing you need is DON'T set the Height of the TextBox in the mark up (ASPX) and then do the following: C# protected void TextBox1_Load(object sender, EventArgs e){ int charRows = 0; string tbCOntent; int chars = 0; tbCOntent = TextBox1.Text; TextBox1.Columns = 10; chars = tbCOntent.Length; charRows = chars / TextBox1.Columns; int ......

Posted On Tuesday, February 17, 2009 4:50 PM

TextBox that Allows Only Numeric Inputs
This simple JavaScript function validates the TextBox input that allows only numeric values to be entered. <script type ="text/javascript" language="javascript" > function ValidateText(i) { if(i.value.length>0) { i.value = i.value.replace(/[^\d]+/g, ''); } } </script> In your textbox add the onkeyup event or onkeypress. <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_Tex... onkeyup = "javascript:ValidateText(th... Note: If you wan't ......

Posted On Tuesday, February 17, 2009 3:54 PM

Restrict number of characters to be entered in the MultiLine TextBox
This example shows how to limit the number of characters to be typed into the TextBox using JavaScript and display the remaining characters in a Label Control. <script type="text/javascript" language="javascript"> function validatelimit(obj, maxchar) { if( obj = this; var remaningChar = maxchar - obj.value.length; document.getElementById('&l... Label1.ClientID %>').innerHTML = remaningChar; if( remaningChar <= 0) { obj.value = obj.value.substring(maxchar... alert('Character ......

Posted On Tuesday, February 17, 2009 3:44 PM

Limit the Number to be Selected in the ListBox
This example shows how to limit the number of Listitems to be selected in the ListBox control. ASPX <html xmlns=" ><head runat="server"> <title>Untitled Page</title> <script type="text/javascript" language="javascript"> function GetCurrentItemsSelected(obj) { var o = obj; document.getElementById('&l... HiddenField1.ClientID %>').value = o; } </script></head>... <form id="form1" runat="server"> <asp:ListBox ......

Posted On Tuesday, February 17, 2009 3:19 PM

Get the Difference Between Two Time in ASP.NET
Here's an example (One Way) on how are we going to calculate the time difference between two give time: C# DateTime dFrom; DateTime dTo; string sDateFrom = "11:56:00"; string sDateTo = "12:12:00"; if (DateTime.TryParse(sDateFrom, out dFrom) && DateTime.TryParse(sDateTo, out dTo)) { TimeSpan TS = dTo - dFrom; int hour = TS.Hours; int mins = TS.Minutes; int secs = TS.Seconds; string timeDiff = hour.ToString("00") + ":" + mins.ToString("00") + ":" + secs.ToString("00"); Response.Write(timeDiff); ......

Posted On Tuesday, February 17, 2009 3:08 PM

Copyright © Vincent Maverick Durano | Powered by: