Control asp:Literal , Intranet Tips: Handling Migration Error: Asp.20 to Asp.net3.5 with IIS 7.0

Objectives:
  • events like click
  • image button
  • and it's coordinates
  • Literal Control : can't be used under span and won't support the properties that a span will embrace.
  • Migration Error from Asp.20 to Asp.net3.5 with IIS 7.0 :
    • Try to addressing an error, than throwing hands in the air

Step1: Create an empty website and then add web form that will add Default.aspx

http://manas6/aspnet.35/mm.cont3/default.aspx

Also add a Web.config file

replace the existing code with the followings

<?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"/>
</system.web>
</configuration>

edit default.aspx 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">

public void method1(object sender, EventArgs e)
{
L1.Text = "You click and got me down <br/>";
L1.Text += "FYI you are using simple function in C# <br/>";

}

protected void method2(object sender, ImageClickEventArgs e)
{
L1.Text += "Below shows image X and Y co-ordinate <hr/>";
L1.Text += "X Co-ordiate : "+ e.X.ToString() + "<br/>";
L1.Text += "Y Co-ordinate : " + e.Y.ToString() + "<br/>";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Simple function and no class</title>
<style type="text/css">
.style1
{
width: 97px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Literal ID="L1" runat="server" ></asp:Literal><br />
<table style="width: 150px; height: 50px;"><tr><td class="style1"><asp:Button ID="b1" Text="Click Me" OnClick="method1" runat="server"/></td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="method2"
ImageUrl="bird.jpg" Height="28px" Width="40px" /></td></tr></table>
</div>
</form>
</body>
</html>
 

View it in browser

Clicking image button

 

Properties of Literal Control

On the hand a Label control will embrace many formatting styles , but no mode.

Now edit the code again

<script runat="server">
void Page_Load()
{
L2.Text = "VSD-2008" + DateTime.Now.ToString("D");
}

public void method1(object sender, EventArgs e)
{
L1.Text = "You click and got me down <br/>";
L1.Text += "FYI you are using simple function in C# <br/>";

}

protected void method2(object sender, ImageClickEventArgs e)
{
L1.Text += "Below shows image X and Y co-ordinate <hr/>";
L1.Text += "X Co-ordiate : "+ e.X.ToString() + "<br/>";
L1.Text += "Y Co-ordinate : " + e.Y.ToString() + "<br/>";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Simple function and no class <asp:Literal ID="L2" runat="server" /></title>

Now let us focus on the few interesting features those displayed during runtime.

Now Click on the Image or "Click Me Button",;

  • you would notice that text in the title bar is duplicated
  • line break <br/> is ingnored

Pass-through will be the normal mode where HTML mark ups are interpreted.

Transform property will strip off any unsupported mark -up, here IE support all the mark-ups so no apparent distinction between Pass-through and Transform

Final Code

default.aspx

<%@ 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 Page_Load()
{
L2.Text += "VSD-2008" + DateTime.Now.ToString("D");
}

public void method1(object sender, EventArgs e)
{
L1.Text = "You click and got me down <br/>";
L1.Text += "FYI you are using simple function in C# <br/>";

}

protected void method2(object sender, ImageClickEventArgs e)
{
L1.Text += "Below shows image X and Y co-ordinate <hr/>";
L1.Text += "X Co-ordiate : "+ e.X.ToString() + "<br/>";
L1.Text += "Y Co-ordinate : " + e.Y.ToString() + "<br/>";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Simple function and no class <asp:Literal ID="L2" runat="server" /></title>
<style type="text/css">
.style1
{
width: 97px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Literal ID="L1" runat="server" Mode="Transform"></asp:Literal><br />

<table style="width: 150px; height: 50px;"><tr><td class="style1"><asp:Button ID="b1" Text="Click Me" OnClick="method1" runat="server"/></td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="method2"
ImageUrl="bird.jpg" Height="28px" Width="40px" /></td></tr></table>

</div>

</form>
</body>
</html>
 

Update Error 500.24 with IIS 7.0

This error can be handled many different ways. Let us keep our options clean, there would be a choice while fixing this kind of server side errors, often due to integration or policy moderations in the server.

I just down loaded ta file and saved from internet  Http_500.24Error_IIS-7.pdf file

"This post lists the changes in behavior that you may encounter
when deploying your ASP.NET applications on IIS 7.0 on Windows
Vista SP1 and Windows Server 2008. Unless noted, these
breaking changes occur only when using the default ASP.NET
Integrated mode."
 

"Using Classic ASP.NET mode
IIS 7.0 also offers the ability to run ASP.NET applications using the legacy Classic ASP.NET Integration mode, which works the
same way as ASP.NET has worked on previous versions of IIS. However, we strongly recommend that you use a workaround
where available to change your application to work in Integrated mode instead. Moving to Classic mode will make your application
unable to take advantage of ASP.NET improvements made possible in Integrated mode, leveraging future features from both
Microsoft and third parties that may require the Integrated mode. Use Classic mode as a last resort if you cannot apply the
specified workaround
. For more information about moving to Classic mode, see: Changing the ASP.NET integration mode."

Work Around:

Solution I:  I worked around simply replacing  Web.config with current version of Visual Studio 2008 Express Edition.

Solution: II : adding this line

 <system.web>
<identity impersonate="true" userName="AdministratorAccount" password="AdministrtorPassWord"/> 
</system.web>

-------for the machine Manas6 ( intranet domain)  it worked

 <system.web><identity impersonate="true" userName="Administrator" password="Manas6"/>  </system.web>