Header Ads Widget

practical-15 || ASP.NET || Use various tags in Web.config file for ASP.NET configuration.

Practical-15

 _ASP.NET


AIM: Use various tags in Web.config file for ASP.NET configuration

Webform1.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="pr15.WebForm1" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <asp:Button ID="Button1" runat="server" Text="Test Stupid URL!!!" />
    </form>
</body>
</html>

Webform1.aspx.vb

Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write("Version : " &
ConfigurationManager.AppSettings("version") & "<br/>")
        Response.Write("Connection string : " &
       ConfigurationManager.ConnectionStrings("myConStr").ConnectionString)

    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        MsgBox("Get Ready to go to a page which doesnt exist!!", MsgBoxStyle.Exclamation)
        Response.Redirect("fasdfasdfsadfasdfasdfsadf.aspx")
    End Sub

End Class

Web.config

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <system.web>
    <compilation debug="true" strict="false" explicit="true"
   targetFramework="4.0" />
    
    <customErrors mode="On" defaultRedirect="error.html"
  
                  redirectMode="ResponseRedirect">
     
      <error statusCode="404" redirect="error.html"/>
   
    </customErrors>
  </system.web>
  <connectionStrings >
    <add name="myConStr"
   connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=E:\Access-2010-B1\PCResale Customer Database.accdb"/>
  </connectionStrings>
  <appSettings>
    <add key="version" value="1.0" />
  </appSettings>
</configuration>




Output:--


















Post a Comment

0 Comments