Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Get username – password - query and scheme associated with uri using “Uri Builder” class in vb.net - C# .net.

Author: Maliha Atteeq
Download Source Code : 1044_sourceCode.zip

In this simple article you will learn that how can we get the username, password, query and scheme associated with the Uri by using “Uri Builder” class in vb and C# .net.

 Uri Builder:

The Uri Builder class provides an easy way to modify the contents of an Uri instance without creating a new Uri instance for each modification. The Uri Builder properties provide read/write access to the read-only Uri properties so that they can be modified.

To get username:

In order to get the username associated with the particular Uri, Uri builder class provides us a property named as UserName. This property returns the username if any associated with the Uri otherwise it returns an empty string. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_username_Click(object sender, EventArgs e)

        {

            string name;

            name = obj.UserName;

            if(name==String.Empty)

            {

              MessageBox.Show("No username is associated with this uri");

            }

            else

            {

            MessageBox.Show("the username associated with uri is "+name);

            }

        }

VB:

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

    Dim name As String

    name = obj.UserName

    If name = [String].Empty Then

        MessageBox.Show("No username is associated with this uri")

    Else

        MessageBox.Show("the username associated with uri is " & name)

    End If

End Sub

 

 

To get password:

In order to get the password associated with the particular Uri, Uri builder class provides us a property named as Password. This property returns the password if any associated with the Uri otherwise it returns an empty string. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

  private void btn_getPswd_Click(object sender, EventArgs e)

        {

            string pswd;

            pswd = obj.Password;

            if (pswd== String.Empty)

            {

                MessageBox.Show("No password is associated with this uri");

            }

            else

            {

                MessageBox.Show("the password associated with uri is " + pswd);

            }

 

        }

VB:

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

    Dim pswd As String

    pswd = obj.Password

    If pswd = [String].Empty Then

        MessageBox.Show("No password is associated with this uri")

    Else

        MessageBox.Show("the password associated with uri is " & pswd)

 

    End If

End Sub

To get scheme:

In order to get the scheme name of the particular Uri, Uri builder class provides us a property named as Scheme. This property returns the scheme name of the Uri. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_getScheme_Click(object sender, EventArgs e)

        {

            string scheme;

            scheme = obj.Scheme;

            MessageBox.Show("the scheme of the uri is " + scheme);

 

        }

VB:

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

    Dim scheme As String

    scheme = obj.Scheme

 

    MessageBox.Show("the scheme of the uri is " & scheme)

End Sub

To set scheme:

In order to set the scheme name use the following code fragment.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_setSchm_Click(object sender, EventArgs e)

        {

            string scheme;

            scheme = txt_setScheme.Text;

            MessageBox.Show("the scheme of the uri is set to " + scheme);

        }

 

VB:

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

    Dim scheme As String

    scheme = txt_setScheme.Text

    MessageBox.Show("the scheme of the uri is set to " & scheme)

End Sub

To get query:

In order to get the query associated with the particular Uri, Uri builder class provides us a property named as Query. This property returns the query if any associated with the Uri otherwise it returns an empty string. The return type of this property is string.

To demonstrate make a new window application. Drag one button on the form and write the following code:

C#:

private void btn_getQry_Click(object sender, EventArgs e)

        {

            string query;

            query=obj.Query;

            if (query == String.Empty)

            {

                MessageBox.Show("No query is associated with this uri");

            }

            else

            {

                MessageBox.Show("the query is " + query);

            }

           

        }

VB:

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

    Dim query As String

    query = obj.Query

    If query = [String].Empty Then

        MessageBox.Show("No query is associated with this uri")

    Else

        MessageBox.Show("the query is " & query)

 

    End If

End Sub

Now write the following code on FORM LOAD event:

C#:

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP APPLICATION";

        }

VB:

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

   Me.Text = "DEVASP APPLICATION"

End Sub

This simple article tells that  how can we get the username, password, query and scheme associated with the Uri by using “Uri Builder” class in vb and C# .net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Get horizontal - vertical resolution clip bounds and clear the frame using “graphics” class in vb.net - C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net