Posts

Donate

How To Reorder Or Rearrange DataColumns In A DataTable Using C#

Here's how to re-order DataColumns in a DataTable. This solves a particular problem in a project I'm currently working with. Code: 1 datatable.Columns[ "Col1" ].SetOrdinal( 1 );

ADO.NET Entity Framework Tutorial

Here's an example from MSDN. There are some minor bugs that I encountered, but this is a good start. ADO.NET Entity Framework in Winforms

Access DOM Elements in ASP.NET WebForms Master And Content Pages Using ClientID And jQuery

The example below will display Bill Murstein in asp.net textbox Example: 1 2 3 4 5 6 var name = 'Bill Murstein' ; //javascript DOM document .getElementById( '<%=txtCustomerName.ClientID%>' ).value = name; //jQuery Counterpart $( '[id$=txtCustomerName]' ).val(name);

jQuery In ASP.NET Web Forms Ajax Does Not Work After Partial Postback

I encountered a problem with jquery in asp.net ajax with master page content. During first pageload, the jquery script works fine, but after partial postback, the jquery script does not work. After a few googling activity, I came upon this site: http://encosia.com/2009/03/25/document-ready-and-pageload-are-not-the-same/ This explains how to use document.ready, pageload, and Application.init. In my previous code, i've used document.ready since my aspx page was not ajax enabled. But since, Im switching my application to ajax ready, the solution I came upon was using function pageLoad() instead of document.ready(). Example: 1 2 3 4 5 6 7 function Pageload() { $( "#txtsomething" ).blur( function () { //your js code here var x = 25 + 25 ; alert(x); }); } Hope this insight will help other developers out there... Here is the summary from the direct link: $(document).ready() Ideal for onetime initialization. Optimization black magic; may

Formatting Numbers With Comma Using Regular Expression In JavaScript

In asp.net c#, this can be achieved by String.Format(), however in javascript/jquery, this can be achieved using a simple JavaScript function: 1 2 3 4 5 6 7 8 9 10 11 function addCommas(nStr) { nStr += '' ; x = nStr.split( '.' ); x1 = x[ 0 ]; x2 = x.length > 1 ? '.' + x[ 1 ] : '' ; var rgx = /(\d+)(\d{3})/ ; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2' ); } return x1 + x2; } In your script, you can call it using: 1 2 3 var number = 123456.99 ; var result = addCommas(number); alert(result); Source: JavaScript Number Format

Manipulating DataTable Columns and Rows

Hi! I found this link to be of help. DataTable Manipulation

CSS Color For ASP.NET Web FormsTextbox In Disabled State

i was wondering what's the hex equivalent of asp.net textbox color rendered in firefox/IE. The default color is: #7F9DB9 (Firefox/chrome/IE) #DADADA (Safari) CSS Code: 1 2 3 4 .Disabled { border-color : #7F9DB9 ; } Or you may use the border attribute and define other properties such as border-style, border-width and border-color.

ScriptManager.RegisterStartupScript() Vs. ClientScript.RegisterStartupScript()

Hi! I have been struggling in manipulating scripts to focus to a particular control when a user executes a button or events triggered by postbacks.The scenario was in every button clicked, the focus will be transferred to another control. These butttons are inside an update panel and ajax tab container. The solution presented in an article i've previously posted was using ClientScript.RegisterStartupScript() to register a script. However, this script is registered in the Page object. But since my controls are inside an update panel which is partial postback rendering, the solution I've come up was using ScriptManager.RegisterStartupScript(). So, to register client scripts on an aspx page w/o ajax functionalities, use ClientScript: 1 ClientScript.RegisterStartupScript( this .GetType(), "MyScript" , script.ToString(), false ); And to register client scripts on an aspx page w/ ajax functionalities such as inside an update panel, use ScriptManager: 1 ScriptManager.

Assign Hexa Color To ASP.NET Control Background Color Property

To convert hexa decimal color to Color in .NET and assign it to a control's background property, do the following: this .lblMachinery.BackColor = ColorTranslator.FromHtml( "#CCCOOO" );

Register Client Scripts In ASP.NET Using ClientScriptManager Class

Source: ClientScriptManager Class C# Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public void Page_Load (Object sender, EventArgs e) { // Define the name and type of the client scripts on the page. String csname1 = "PopupScript" ; String csname2 = "ButtonClickScript" ; // Get a ClientScriptManager reference from the Page class. System.Web.UI.ClientScriptManager cs = Page.ClientScript; // Check to see if the startup script is already registered. if (!cs.IsStartupScriptRegistered(csname1)) { String cstext1 = "alert('Testing');" ; cs.RegisterStartupScript(GetType(), csname1, cstext1, true ); } // Check to see if the client script is already registered. if (!cs.IsClientScriptBlockRegistered(csname2)) { StringBuilder cstext2 = new StringBuilder(); cstext2.Append( "" ); cs.RegisterClientScriptBlock(GetType(), csname2, cstext2.ToString(), false ); } } HTML Markup 1 2 3 4 5 6

Donate