9
1) Master Page Example with Menu <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!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> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> <style type="text/css"> .style1 { text-align: center; } #form1 { width: 1078px; text-align: right; } </style> </head> <body> <p class="style1" style="font-family: 'Times New Roman', Times, serif; font-size: xx-large; color: #FFFFFF; background-color: #FFFFFF; background-image: url('/Web/headerbig3.jpg');"> <br style="background-color: #FFFFFF" /> <br style="background-image: url('/Web/headerbig3.jpg')" /> ICS College, Khed.<br /><br /> Dept. of IT/CS/BMS<br /> </p> <form id="form1" runat="server"> <asp:Menu ID="Menu1" runat="server" BackColor="#990033" DynamicHorizontalOffset="2" Font-Names="Times New Roman" Font-Size="Large" ForeColor="#7C6F57" Orientation="Horizontal" StaticSubMenuIndent="10px" Width="504px"> <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" /> <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <DynamicMenuStyle BackColor="#F7F6F3" /> <DynamicSelectedStyle BackColor="#5D7B9D" />

C#.Net

Embed Size (px)

DESCRIPTION

C#.Net

Citation preview

Page 1: C#.Net

1) Master Page Example with Menu

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> <style type="text/css"> .style1 { text-align: center; } #form1 { width: 1078px; text-align: right; } </style></head><body> <p class="style1" style="font-family: 'Times New Roman', Times, serif; font-size: xx-large; color: #FFFFFF; background-color: #FFFFFF; background-image: url('/Web/headerbig3.jpg');"> <br style="background-color: #FFFFFF" /> <br style="background-image: url('/Web/headerbig3.jpg')" /> ICS College, Khed.<br /><br /> Dept. of IT/CS/BMS<br />

</p> <form id="form1" runat="server"> <asp:Menu ID="Menu1" runat="server" BackColor="#990033" DynamicHorizontalOffset="2" Font-Names="Times New Roman" Font-Size="Large" ForeColor="#7C6F57" Orientation="Horizontal" StaticSubMenuIndent="10px" Width="504px"> <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" /> <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /> <DynamicMenuStyle BackColor="#F7F6F3" /> <DynamicSelectedStyle BackColor="#5D7B9D" /> <DynamicItemTemplate><%# Eval("Text") %> </DynamicItemTemplate> <Items> <asp:MenuItem NavigateUrl="~/Institute.aspx" Text="Institute" Value="Institute"> </asp:MenuItem> <asp:MenuItem NavigateUrl="~/Acaemics.aspx" Text="Academics" Value="Academics"> </asp:MenuItem> <asp:MenuItem Text="Staff" Value="Staff"></asp:MenuItem> </Items> <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" /> <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

Page 2: C#.Net

<StaticSelectedStyle BackColor="#5D7B9D" /> </asp:Menu> <asp:TreeView ID="TreeView1" runat="server"> <Nodes> <asp:TreeNode NavigateUrl="~/About_ICS.aspx" Text="About ICS" Value="About ICS"> </asp:TreeNode> <asp:TreeNode Text="Vision &amp; Mission" Value="Vision &amp; Mission"> </asp:TreeNode> <asp:TreeNode Text="Our Inspiration" Value="Our Inspiration"></asp:TreeNode> <asp:TreeNode Text="Directors Message" Value="Directors Message"></asp:TreeNode> </Nodes> </asp:TreeView> <div> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> <p style="margin-left: 100px"> <br /> </p> </asp:ContentPlaceHolder> </div> </form></body></html>

Output:

Page 3: C#.Net

Validation Control

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="validation.aspx.cs" Inherits="validation" %>

<!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> <style type="text/css"> .style1 { text-align: center; font-size: xx-large; } </style></head><body> <form id="form1" runat="server"> <div> <table style="width:100%;"> <tr> <td class="style1" colspan="2"> <strong>Validation Control</strong></td> </tr> <tr> <td> Name:</td> <td> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1"></asp:RequiredFieldValidator> </td> </tr> <tr> <td> Contact No.:</td> <td> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Plz Enter Valid No."></asp:RequiredFieldValidator> </td> </tr> <tr> <td> Address:</td> <td> <asp:TextBox ID="TextBox3" runat="server" Rows="5"></asp:TextBox> </td> </tr> <tr> <td> Date of Join:</td> <td> <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox> <asp:RangeValidator ID="RangeValidator2" runat="server"

Page 4: C#.Net

ControlToValidate="TextBox4" ErrorMessage="Plz Enter Valid Date" MaximumValue="05/31/2011" MinimumValue="03/01/2011">Enter date of March, April or May 2011</asp:RangeValidator> </td> </tr> <tr> <td> Email ID:</td> <td> <asp:TextBox ID="TextBox5" runat="server" Width="220px"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox5" ErrorMessage="Valid Email Address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator> </td> </tr> <tr> <td> &nbsp;</td> <td> &nbsp;</td> </tr> </table> <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" /> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" /> <br /> </div> </form></body></html>

Output:

Page 5: C#.Net

Jquery

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jquery.aspx.cs" Inherits="Default2" %>

<!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> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $(":button").click(function () { $("table").hide(); }); }); </script></head><body> <form id="form1" runat="server"> <div> <table border="1"> <tr><td>1</td><td>2</td><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td><td>7</td><td>8</td></tr> <tr><td>9</td><td>10</td><td>11</td><td>12</td></tr> </table> <br /> <input type="button" value="Hide the Table" />

</div> </form></body>

Page 6: C#.Net

</html>

Output:

Page 7: C#.Net

Ajax

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Ajax.aspx.cs" Inherits="Ajax" %>

<!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> <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "ajax_info.txt", true); xmlhttp.send(); }</script></head><body> <form id="form1" runat="server"> <div id="myDiv"><h2>Let AJAX change this text</h2></div><button type="button" onclick="loadXMLDoc()">Change Content</button> </form></body></html>

Output:

Page 8: C#.Net