1)HyperLink Control:
- Using this Control we can redirect the user request from one page to other page or from one website to other website
- Using hyperlink Control we can create link for both text & images
- Hyperlink Control doesn’t support Command name & Command argument properties
Properties with Hyperlink Control:
- ImageUrl
- NavigateUrl
- Text
- Target
ImageUrl:This property is used to set the part of image or Url address of the image for which we want to create the HyperLinkNavigateUrl:This property is used to set the target Url address to which we would like to Redirect the user requestText:This property is used to set the display text to the userTarget:This property is used to set the target frame name in which we want to display the target page
Example with HyperLink Control
Create a New
WebPage Design the WebPage
- Create HyperLlink Control then Select HyperLink1
- Go to properties window type lnkSampleIn ID property
- type Google In text property
- Go to navigate Url property Type http://www.Google.com
- Run the Application and check
To create link for image use the following steps:
- Copy the required image and paste into your website Application
- Select hyperlink we go to properties window
- Go to ImageUrl property
- Click on Ellipsis Button
- Select the image file
- Click on Ok
Run the Application and check
2)Link Button Control:
- This Control is used to Redirect the user request from one webpage to other webpage (or) from one website to other website
- Using this Control we can create a link only to the text but we cannot create to the image, this Control will support Command name and Command argument on client click properties
- This Control also support PostBack nature of a WebPage
Properties with Link Button Control:
1. CommandName
2. Command argument
3. PostBackUrl
4. OnClientClick
5. Text
PostBackUrl:
This property is used to set the required URL address to which we would be like to redirect the user request
Create a New webpage,Design the Webpage
- Go to tool box
- Double click on LinkButton
- Select LinkButton1
- Go to properties window
- Type btnSample in ID property
- Type Google in text property
- Go to PostBackUrl property
- Type http://www.Google.co.in
- Run the Application and check
3)Image Button Control:
- This Control is used to Redirect by user request from one website to other website or from one webpage to other webpage
- Using this Control we can create the link for images only and cannot create for the text
- This Control supports CommandName & CommandArgument properties
Properties with image Button Control:
1. CommandArgument
2. CommandName
3. Onclient click
4. PostBackUrl
5. ImageUrl
Example with ImageButton Control:
- Create ImageButton Control
- Select ImageButton1
- Go to properties window
- Type ibtnSample in ID property
- Go to ImageUrl property
- Click on Ellipsis Button
- Select the required image file
- Click on Ok
- Go to PostBackUrl property
- Click on Ellipsis Button
- Type the URL as http://www.Google.co.in
- Click on Ok
- Run the Application & Check
4) Button Control:
- Though facilities available using this Control to Redirect the request to other webpage or website this Control is used Rarely in Real Time Programming
- Using this Control we can create only for text not for the image
Properties with Button Control:
1. Command argument
2. Command name
3. Onclient click
4. PostBack URL
5. Text
2. Command name
3. Onclient click
4. PostBack URL
5. Text
Example with Button
Control:
Create a New WebPage ,Design the WebPage
Create a New WebPage ,Design the WebPage
- Create Button Control
- Select Button1
- Go to properties window, type btnSample in ID Property
- Type Google in Text property
- Go to PostBackUrl Property
- Type http://www.Google.com
- Run the Application and check
Difference among HyperLink,
Link Button, Image Button & Button Control:
SNO
|
Hyper link
|
Link Button
|
Image Button
|
Button
|
01
|
Can
create a link for both text & image
|
Can
create a link only for text
|
Can
create a link only for image
|
Can
create link for only for text
|
02
|
Does
not support Command argument and Command name properties
|
Supports
Command argument and Command name properties
|
Supports
Command argument and Command name properties
|
Supports
Command argument and Command name properties
|
03
|
Does
not supports PostBack nature
|
Supports
PostBack nature
|
Supports
PostBack nature
|
Supports
PostBack nature
|
04
|
Does
not supports Onclient click property
|
Supports
Onclient click property
|
Supports
Onclient click property
|
Supports
Onclient click property
|
05
|
Does
not support click & Command Event
|
Supports
click and Command Event
|
Supports
click and Command Event
|
Supports
click and Command Event
|
Working with RunTime Code:-
- We know that in coding part we use Server.Transfer () & Response.Redirect( )
- Syntax of both methods is
- Response.Redirect(“Target page/URL address”);
- Server.Transfer(“Target page address”);
- Using Server.Transfer( ) we can Redirect the user request to any page within the same Website only and cannot be able to Redirect to the pages in other websites
- Response.Redirect( ) is used to Redirect the user request to any page within the any website
Differences between Server.Transfer & Response.Redirect:
SNO
|
Response.Redirect()
|
Server.Transfer()
|
01
|
Used
to Redirect to any webpage in any website
|
Used
to Redirect to any webpage in current website only
|
02
|
Can
be used to pass the required values from source page to target page while
redirecting
|
Cannot
be used to pass the required values from source page to target page while
redirecting
|
03
|
Execution
is slow
|
Execution
is fast
|
04
|
Target
page address appears within the address bar
|
Target
page address does not appear within the address bar
|
05
|
Refreshing
of the page does not cause any error
|
Refreshing
of the page cause error
|
Example to work with Server.Transver( ) & Response.Redirect( )
Set the Following
Properties for Button1
ID --- btnGoogle
Name --- Google
Set the Following
Properties for Button2
ID --- btnDefaut2
Name --- Default2
Goto Source & Write
the following code.
protected void btnGoogle_Click(object sender, EventArgs
e)
{
Response.Redirect("http://www.google.com");
}
protected void
btnDefault2_Click(object sender, EventArgs e)
{
Server.Transfer("Default2.aspx");
}
|
Run the Application & Check
No comments:
Post a Comment