BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


.NET and XML
XML Serialization and .Net
Dynamic Method Invocation in .NET using Reflection API
Using XML classes in .Net
Pass node sets to XSLT stylesheets using .NET
Output a directory as XML using .NET
.Net, COM Interoperability and Word Object Model
WS-Routing for .NET endpoints
Using XML and XSLT in VB.NET Jeopardy
Symmetric Encryption/Decryption with .NET
XInclude.NET 1.0
EXSLT.NET 1.0
How to read a XML file using XmlTextReader?
How to compare a XML element with XmlTextReader?
How to verify if an element is empty with XmlTextReader and IsEmptyElement?
How to check if the XML elements contains any attributes with XmlTextReader
How to avoid to read the XML declaration with XmlTextReader?
How to create a XML file with XmlTextWriter?
Is it possible to add attributes with XmlTextWriter?
How to Write a Comment to a XML File with XmlTextWriter and WriteComment?
How to add the XML Declaration with XmlTextWriter and WriteStartDocument?


 
 

<< XSLT 


By Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First Posted 03/05/2002
Times viewed 472

String Handling Application using ASP.NET


This post contains attachments
v20020304235156.zip 

Summary In this article I designed an application, which gives you the output for your selected/entered input string. Basically, this application shows how your given input string is handled by various string methods like ToLower, ToUpper, Split, StartsWith, EndsWith, IndexOf, LastIndexOf.

In this article, I will explain how various concepts of ASP.NET programming were implemented in the designed application.

It covers how you can

separate code from the presentation content

use server controls in the web page

write the class where it can be implemented as component

control the page events

attach events to the controls/objects

write the same application in languages like VB.Net and C#.Net

 

Separation of code from presentation content

It is good idea to have code separated from presentation content. With this kind of strategy, you can design and develop components easily and efficiently.

In my application, I separated the code by creating StringTest.cs and StringTest.vb files.

If you look at the code in stringtest.aspx, I am inheriting the code in Page directive as follows:

 

In C# language:

<%@ Page Language=c# Src=StringTest.cs Inherits=PanduTest.StringTest%>

 

In VB language:

<%@ Page Language=VB Src=StringTest.vb Inherits=PanduTest.StringTest%>

 

Here PanduTest is the namespace and StringTest is the class name.

 

When you call PanduTest.StringTest, the class constructor gets called.

In C#, the following function is being invoked.

public StringTest()

{

            Page.Init += new System.EventHandler(Page_Init);

}

 

In VB,

Public Sub New()

            AddHandler Page.Init, AddressOf Page_Init

End Sub

Here Page_Init is being fired in the class constructor. In this constructor, I attached Page Init event.

 

In InitializeComponent function, I attached event handlers to Page Load, Button Click, DropDownList SelectChange Events as follows:

 

In VB,

Private Sub InitializeComponent

AddHandler Page.Load, AddressOf Page_Load

            AddHandler cmdShow.Click, AddressOf cmdShow_Click

            AddHandler dlStringFun.SelectedIndexChanged, AddressOf dlStringFun_OnSelectedIndex

End Sub

 

In C#,

private void InitializeComponent()

{

            Page.Load += new System.EventHandler(this.Page_Load);

            cmdShow.Click += new System.EventHandler(cmdShow_Click);

            dlStringFun.SelectedIndexChanged += new System.EventHandler ( dlStringFun_OnSelectedIndex);

}

 

I implemented server controls like Label, DropDownList, TextBox, TableRow, TableCell, Table elements. Please see source code file “stringtest.aspx”, which gives you clear idea, how to implement these server side controls.

 

When the user selects the option in the DropDownList, TextBox(s) will be displayed dynamically and the label text will change accordingly.

In C#,

private void dlStringFun_OnSelectedIndex(Object sender, EventArgs e)

{

 .......

}

In VB,

Private Sub dlStringFun_OnSelectedIndex(ByVal sender As Object, ByVal e As EventArgs)

 .......

End Sub

 

The above function handles the DropDownList SelectedIndex event.

 

When you click the Show Button, the System.String methods will be applied to the given input string(s) and the message will be displayed at the bottom of the button.

 

I tested this application successfully with .Net SDK Beta 1 version on Windows 2000 OS.

By using this kind of programming approach, you can implement the concept in various applications. If you have any questions, please do feel free to contact me.

Additional information

Further additional information


Rate this article on a scale of 1 to 10 (1 votes, average 5)

Your vote :  

<< XSLT 





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML