In this chapter we we will discuss
  • how to rename a project
  • link Button
  • jmage button
  • focus
  • PostBackUrl this function will post back to the same page.

Step : 1

add a default.aspx using webform

add an web.config file

Use this code

<?xml version="1.0"?>
<configuration>
<system.web>
<authentication mode="Forms">
<forms loginUrl="default.aspx" protection="All" timeout="60"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true"/>
<customErrors mode="Off"/>
</system.web>
</configuration>

 

Add a Link Button

Now click on Link-Me and it will add few lines of codes to begin with

You may adjust the properties of these controls from style or using a local style module.

Now also add an Image-button, to insert an image we need to set an url to image that should be recognized by the IDE.

In VSD-2008, the mere presence of an image in the same folder, won't make it not visible in the solution explorer unless you add as an existing item.

Now it is visible in the solution explorer, note the html page is not seen by the IDE.

Use image-button properties, set the image as show below

The image is added, but need be adjusted

Now add a Label control to show the type of the button.

 

Code

<%@ Page Language="C#" debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

void label_clear()
{
Label1.Text = "";
}
protected void LB1_Click(object sender, EventArgs e)

{
label_clear();
Label1.Text += sender.ToString();

}


protected void IB1_Click(object sender, ImageClickEventArgs e)
{
label_clear();
Label1.Text += sender.ToString() + "<br/>";
Label1.Text += "X cord: " + e.X.ToString() + " Y Cord : " + e.Y.ToString();

}
void Page_load()
{
IB1.Focus();
Label1.Text = " Load activation ";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>mm.cont6</title>
</head>
<body>The page shows how to sue link-button, image control, Autopostback=True
<br />Manipulating Div features using style in property pane:&nbsp; width: 200px; font-family: 'Book Antiqua'; background-color: #C0C0C0 <br />
<form id="form1" runat="server">
<div style="width: 250px; font-family: 'Book Antiqua'; background-color: #C0C0C0;"
align="center">
<asp:LinkButton runat="server" ID="LB1" Text="Link Me" onclick="LB1_Click"
BorderColor="#CC6600" BorderStyle="Solid" Height="25px" PostBackUrl="~/Default.aspx"
/>&nbsp;&nbsp;&nbsp;
<asp:ImageButton ID="IB1" runat="server" BorderColor="#CC33FF"
BorderStyle="Solid" BorderWidth="4px" Height="21px" ImageUrl="~/chick.gif"
Width="32px" ImageAlign="Bottom" onclick="IB1_Click" PostBackUrl="~/Default.aspx"
/>

&nbsp;
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
 

Run Time descriptions:

As Focus is set on image button you will note the corresponding output in the label. Before you run, just click on left side of IB1.Focus as shown in the image below. During runt time the cursor will pause here, press F10 to move step by step or press F11 to get out of the debug mode.

Click on Link Me

Debug will start from page Load, then move to the LB1_click method