How do I debug an asp.net program without code behind? - asp.net

I inherited a web site that I know little about. I've worked with asp.net/C# websites, but this seems to be something different. There is no code behind for me to put a break point and step through it. Also several refernces in the program can't be found. My general question is: How do I debug this program in Visual Studio?
Specifc questions related to this sample code:
Where do I put my break point?
What happens in this sample when a user clicks the submit button?
The program inherits "Company.Program.SystemLogin". I can't find that class in any of the code. Why not and how do I find it?
<%# Page Language="vb" AutoEventWireup="false" Inherits="Company.Program.SystemLogin" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Company CMS</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<style>
BODY { FONT-SIZE: 11px; FONT-FAMILY: Verdana, Helvetica, sans-serif; BACKGROUND-COLOR: #ffffff }
INPUT { FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, sans-serif }
TEXTAREA { FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, sans-serif }
SELECT { FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: Verdana, Helvetica, sans-serif }
TD { FONT-SIZE: 11px; FONT-FAMILY: Verdana, Helvetica, sans-serif }
.red { FONT-WEIGHT: bold; COLOR: #851205 }
.orange { FONT-WEIGHT: bold; COLOR: #e05e02 }
.message { FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #e05e02 }
</style>
</HEAD>
<body onload="document.getElementById('txtUsername').focus();">
<form id="Form1" method="post" runat="server">
<table width="400" cellpadding="3" cellspacing="3" align="center">
<tr>
<td colspan="2" align="center"><img src="images/pcms.jpg" alt="Company CMS"></td>
</tr>
<tr>
<td colspan="2" align="center"><asp:Label ID="lblMessage" Runat="server" CssClass="message">PLEASE LOGIN</asp:Label></td>
</tr>
<tr>
<td align="right" class="red">Username</td>
<td><asp:TextBox ID="txtUsername" Runat="server" />
<asp:RequiredFieldValidator ID="rUsername" Runat="server" ControlToValidate="txtUsername" Text="*" Font-Bold="True"
Display="Dynamic" ForeColor="#E05E02" /></td>
</tr>
<tr>
<td align="right" class="red">Password</td>
<td><asp:TextBox ID="txtPassword" Runat="server" TextMode="Password" />
<asp:RequiredFieldValidator ID="rPassword" Runat="server" ControlToValidate="txtPassword" Text="*" Font-Bold="True"
Display="Dynamic" ForeColor="#E05E02" /></td>
</tr>
<tr>
<td align="right" class="red"><asp:label id="lblconn" Runat="server" Visible="False">Connection:</asp:label></td>
<td><asp:DropDownList ID="conns" Runat="server" Visible="False">
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td colspan="2" align="center"><asp:Button id="btnSubmit" Runat="server" Text="Log In" CssClass="button" /></td>
</tr>
</table>
</form>
</body>

If you have inherited an application without source code, you have a tough challenge ahead of you.
You could use dotpeek or reflector to decompile the DLLs in order to recreate the source code, but this will be an onerous task.
My first point of call would be to find out if the source code was available anywhere.

Related

.Net - Display multiple placeholders within in a table

We are using the below code. We want these two placeholder to display next to each other. But when we run this, Placeholder1 comes underneath Placeholder2.
Requirement is to place both placeholder next to each other
<table>
<tr>
<td>
<asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
</td>
<td>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</td>
</tr>
</table>
HTML generated by code:
<table>
<tr>
<td> <br />
</td>
<td>
<table border='1' class='table table-striped' width='450'><tr><th>Document Name</th><td>LMA2.doc</td></tr><tr><th>Uploaded Date</th><td>01 Aug 2018</td></tr></table><table border='1' class='table table-striped' width='450px'><tr><th>Facilities</th><th>Size</th><th>InterestRate</th></tr><tr ><td>A</td><td>11 million</td><td>8</td></tr><tr ><td>B</td><td>15 million</td><td>4.5</td></tr><tr ><td>C</td><td>20 million</td><td>6.6</td></tr></table>
</td>
</tr>
</table>
CSS:
.table-striped tbody tr:nth-of-type(odd) {
/*background-color: rgba(0, 0, 0, .02);
width:800px;*/
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 80%;
}

How to disable controls inside a <TD> for FF and Chrome. IE ok

I have a few checkbox controls inside a <td> that I need to disable so users cannot check the checkboxes.
This all works in IE8 and above, but FF or Chrome, the disable="disabled" is ignored. Why and how can I get around this please?
<td id="tdDocs" runat="server" style="table-layout: fixed; visibility: visible; overflow: auto; border-collapse: separate; font-size: 12pt; vertical-align: top; text-align: left; font-weight: bold; font-family: Arial; background-color: transparent; width: 799px; background-image: none;" colspan="2">
<strong>What documents will be required for today's tasks?<br /></strong>
<span style="font-size: 9pt">(Please ensure supporting documentation is attached)</span>
<asp:CustomValidator ID="CustomValidator12" runat="server"
ErrorMessage='Tick one of the "Documents required today" section tick boxes.' OnServerValidate="CustomValidator12_ServerValidate" ValidationGroup="ValidationGroup1" Font-Names="Arial" Font-Size="9pt">*</asp:CustomValidator><br />
<table style="width: 651px; font-weight: bold; font-size: 10pt; font-family: Arial;">
<tr>
<td style="font-size: 10pt; font-family: Arial; height: 22px; font-weight: bold; width: 247px;">
<strong>
<asp:CheckBox ID="chkJSEA" runat="server" Text="JSEA" Width="200px" Font-Names="Arial" Font-Size="10pt" ValidationGroup="ValidationGroup1" /></strong></td>
<td style="height: 22px; font-weight: bold; font-size: 10pt; width: 278px; font-family: Arial;"><asp:CheckBox ID="chkRISKA" runat="server" Text="Risk Assessment" Width="200px" Font-Bold="True" Font-Names="Arial" Font-Size="10pt" ValidationGroup="ValidationGroup1" /></td>
<td style="height: 22px; font-weight: bold; font-size: 10pt; width: 121px; font-family: Arial;"><asp:CheckBox ID="chkWMS" runat="server" Text="Work Method Statement" Width="200px" Font-Bold="True" Font-Names="Arial" Font-Size="10pt" ValidationGroup="ValidationGroup1" /></td>
</tr>
<tr>
<td style="font-size: 12pt; width: 247px; font-family: Arial; height: 22px;">
<strong>
<asp:CheckBox ID="chkSOP" runat="server" Text="Safe Operating Procedures" Width="200px" Font-Names="Arial" Font-Size="10pt" ValidationGroup="ValidationGroup1" /></strong></td>
<td style="height: 22px" colspan="2">
<asp:CheckBox ID="chkOTHER" runat="server" Text="Other" OnCheckedChanged="chkOTHER_CheckedChanged" AutoPostBack="true" ValidationGroup="ValidationGroup1" />
<asp:TextBox ID="txtOtherFlag" runat="server" AutoPostBack="True" ValidationGroup="ValidationGroup1" ></asp:TextBox>
</td>
</tr>
</table>
</td>
In code-behind, I have logic to disable this row and everything in it with one line...
tdDocs.Disabled = True;
IE does indeed disable all controls inside a td (or any container) if you set its disabled attribute. I didn't even know that!
But the problem is that other browsers don't. disabled is not a valid attribute for a td. See this fiddle, where the checkbox in the table becomes unclickable in IE, but not in the other browsers.
Solution: disable all controls individually by running a quick loop over all the controls in the td.
So instead of
tdDocs.Disabled = true;
write
foreach (Control ctrl in tdDocs.Controls) {
if (ctrl is WebControl) ((WebControl)ctrl).Enabled = false;
}

Adding a stylesheet to asp.net (using Visual Studio 2010)

I am trying to add a stylesheet to a master page in an asp.net web form. Basically trying to create an inline nav menu for the top of the page. I'm having issues with it. I've created the stylesheet (the same way I would create if this were an html site) and I've put it in the directory you see below. I don't see how the code below shows any relation to the stylesheet though.
Like in html, I would have
Home
About
Contact
And then my stylesheet would look like this...
ul {
list-style-type:none;
margin:0;
padding:0;
}
li {
display:inline;
padding:20px;
}
And the CSS would let it display inline (across the top). But I'm not sure where to go here.
<%# 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>AR Toolbox</title>
<asp:ContentPlaceHolder id="Stylesheets" runat="server">
<link rel="Stylesheet" href="/css/master.css" type="text/css" />
</asp:ContentPlaceHolder>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
height: 459px;
}
.style3
{
width: 100%;
height: 100%;
}
.style6
{
height: 79px;
}
.style7
{
width: 345px;
height: 73px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td style="background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;"
class="style6">
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem Text="About" Value="About"></asp:MenuItem>
<asp:MenuItem Text="Compliance" Value="Compliance">
<asp:MenuItem Text="Item 1" Value="Item 1"></asp:MenuItem>
<asp:MenuItem Text="Item 2" Value="Item 2"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Tools" Value="Tools"></asp:MenuItem>
<asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td style="background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;"
class="style6">
<img alt="South University'" class="style7"
src="file:///C:/Users/jnewnam/Documents/Visual%20Studio%202010/WebSites/WebSite1/img/suo_n_seal_hor_pantone.png" /></td>
</tr>
<tr>
<td class="style2">
<table class="style3">
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="color: #FFFFFF; background-color: #A3A3A3">
This is the footer.</td>
</tr>
</table>
</form>
</body>
</html>
Several things here.
First off, you're defining your CSS in 3 places!
In line, in the head and externally. I suggest you only choose one. I'm going to suggest externally.
I suggest you update your code in your ASP form from
<td style="background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;"
class="style6">
to this:
<td class="style6">
And then update your css too
.style6
{
height: 79px; background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;
}
This removes the inline.
Now, to move it from the head of the webForm.
<%# 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>AR Toolbox</title>
<link rel="Stylesheet" href="css/master.css" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td class="style6">
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem Text="About" Value="About"></asp:MenuItem>
<asp:MenuItem Text="Compliance" Value="Compliance">
<asp:MenuItem Text="Item 1" Value="Item 1"></asp:MenuItem>
<asp:MenuItem Text="Item 2" Value="Item 2"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Tools" Value="Tools"></asp:MenuItem>
<asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>
</Items>
</asp:Menu>
</td>
</tr>
<tr>
<td class="style6">
<img alt="South University'" class="style7"
src="file:///C:/Users/jnewnam/Documents/Visual%20Studio%202010/WebSites/WebSite1/img/suo_n_seal_hor_pantone.png" /></td>
</tr>
<tr>
<td class="style2">
<table class="style3">
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="color: #FFFFFF; background-color: #A3A3A3">
This is the footer.</td>
</tr>
</table>
</form>
</body>
</html>
Now, in a new file called master.css (in your css folder) add
ul {
list-style-type:none;
margin:0;
padding:0;
}
li {
display:inline;
padding:20px;
}
.style1
{
width: 100%;
}
.style2
{
height: 459px;
}
.style3
{
width: 100%;
height: 100%;
}
.style6
{
height: 79px; background-color: #A3A3A3; color: #FFFFFF; font-family: 'Arial Black'; font-size: large; font-weight: bold;
}
.style7
{
width: 345px;
height: 73px;
}
Add your style here:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="BSC.SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="~/Styles/NewStyle.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
Then in the page:
<asp:Table CssClass=NewStyleExampleClass runat="server" >
The only thing you have to do is to add in the cshtml file, in the head, the following line:
#Styles.Render("~/Content/Main.css")
The entire head will look somethink like that:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>HTML Page</title>
#Styles.Render("~/Content/main.css")
</head>
Hope it helps!!

ModalPopupExtender dosenot show up and display blank page

hi,
I had aproblem on model popup extender as I used it well , I did my code well .but when I was testing it it didnot show up only blank page appeared.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
.ModalPopupBG
{
background-color: #666699;
filter: alpha(opacity=50);
opacity: 0.7;
width: 500px;
height: 300px;
}
.btnadd
{
background-image: url('Content/Images/add.png');
height: 27px;
width: 78px;
border: none;
background-repeat: no-repeat;
cursor: pointer;
}
.calhover
{
cursor: pointer;
vertical-align: baseline;
}
.z
{
clear: both;
height: 1px;
}
.tile
{
background-image: url('Content/Images/tile.png');
background-repeat: repeat-y;
width: 437px;
background-position: right;
color: White;
font-weight: bold;
}
.activetab
{
background-color: Green;
font-size: 50px;
}
.accordion
{
width: 770px;
}
.accordionHeader
{
border: 1px solid #2F4F4F;
color: white;
background-color: #2E4d7B;
font-family: Arial, Sans-Serif;
font-size: 12px;
font-weight: bold;
padding: 5px;
margin-top: 5px;
cursor: pointer;
}
.accordionHeaderSelected
{
border: 1px solid #2F4F4F;
color: white;
background-color: #5078B3;
font-family: Arial, Sans-Serif;
font-size: 12px;
font-weight: bold;
padding: 5px;
margin-top: 5px;
cursor: pointer;
}
.accordionContent
{
background-color: #D3DEEF;
border: 1px dashed #2F4F4F;
border-top: none;
padding: 5px;
padding-top: 10px;
}
</style>
<script type="text/javascript">
function ValidateCheckBox1(sender, args) {
if (document.getElementById("<%=CheckBox1.ClientID %>").checked == true) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
<script type="text/javascript">
function ValidateCheckBox2(sender, args) {
if (document.getElementById("<%=CheckBox2.ClientID %>").checked == true) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
<script type="text/javascript">
function ValidateCheckBox3(sender, args) {
if (document.getElementById("<%=CheckBox3.ClientID %>").checked == true) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
<ContentTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="body_con ">
<div class="bf_body_d">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="top">
<td>
</td>
<td class="body_content" valign="top">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="3">
<tr>
<td style="border: #3399FF">
<table width="100%" border="0" cellspacing="3" cellpadding="2">
<tr>
<td width="100%" class="style1" align="left">
<h3 style="color: Gray; font-size: large;">
Questions</h3>
<h2>
Please be aware that your answer on both questions might be used by HR to screen
your application.</h2>
</td>
</tr>
<tr>
<td class="style1" align="left">
<asp:DataList ID="Dl_Question" runat="server" OnItemDataBound="Dl_Question_ItemDataBound"
OnItemCommand="Dl_Question_ItemCommand">
<ItemTemplate>
<asp:Label ID="lbl_QID" runat="server" Text='<%# Eval("ID") %>' Visible="false"></asp:Label><br />
<asp:Label ID="Lbl_Question" runat="server" Text='<%# Eval("Question") %>'></asp:Label><br />
<textarea id="Txt_Answer" cols="75" rows="3" runat="server"></textarea>
<asp:RequiredFieldValidator ID="RequiredFieldValidator22" runat="server" ControlToValidate="Txt_Answer"
ErrorMessage="*" Display="Dynamic" SetFocusOnError="True" ForeColor="Red" ValidationGroup="question">*</asp:RequiredFieldValidator>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td width="100%" class="style1" align="left" valign="top">
<h3 style="color: Gray; font-size: medium;">
Upload Your CV
</h3>
<asp:FileUpload ID="FU_CV" runat="server" />
<asp:CustomValidator ID="CustomValidator" runat="server" ControlToValidate="FU_CV"
ErrorMessage="File size should not be greater than 4 MB." OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator22" runat="server" ControlToValidate="FU_CV"
ErrorMessage="*" Display="Dynamic" SetFocusOnError="True" ForeColor="Red" ValidationGroup="question">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td valign="top">
<div>
<asp:Panel ID="Panel2" runat="server">
<h2 style="color: Blue; font-size: medium;">
Please certify the information supplied before submitting your CV by checking the
checkbox below .</h2>
<h2 class="dark_gray">
<asp:CheckBox ID="CheckBox1" runat="server" />
<span>I certify that all answers given herein are true and complete.
<asp:CustomValidator ID="CustomValidator1" runat="server" ForeColor="Red" ErrorMessage="*"
ClientValidationFunction="ValidateCheckBox1" ValidationGroup="question"></asp:CustomValidator>
</span>
<br />
<asp:CheckBox ID="CheckBox2" runat="server" />
<span>I authorize investigation of all statements contained in this application for
employment as may be necessary in arriving at an employment decision.
<asp:CustomValidator ID="CustomValidator2" runat="server" ForeColor="Red" ErrorMessage="*"
ClientValidationFunction="ValidateCheckBox2" ValidationGroup="question"></asp:CustomValidator></span>
<br />
<asp:CheckBox ID="CheckBox3" runat="server" />
<span>I hereby certify that all the above data is true and correct. If proven otherwise,
I will be dismissed without any notice or commitment from the employer.
<asp:CustomValidator ID="CustomValidator3" runat="server" ForeColor="Red" ErrorMessage="*"
ClientValidationFunction="ValidateCheckBox3" ValidationGroup="question"></asp:CustomValidator>
</span>
</h2>
</asp:Panel>
<div align="center" style="padding-top: 10px;">
<asp:ImageButton ID="preup" runat="server" ImageUrl="~/Content/Images/down.png" OnClick="preup_Click" />
<asp:ImageButton ID="BT_submit" runat="server" ImageUrl="~/Content/Images/finish.png"
OnClick="BT_submit_Click" ValidationGroup="question" /></div>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</td>
<!-- Kareem end here plz -->
</tr>
</table>
</div>
</td>
</tr>
</table>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
<cc1:ModalPopupExtender ID="modalpopup" runat="server" OkControlID="btnOkay" TargetControlID="hfield"
PopupControlID="display" PopupDragHandleControlID="PopupHeader" Drag="true" BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
<asp:HiddenField ID="hfield" runat="server" />
<asp:Panel ID="display" Style="display: none" runat="server">
<div>
<img src="Content/Images/warning.png" />
</div>
<div align="center">
<input id="btnOkay" type="button" value="OK" />
</div>
</asp:Panel>
protected void BT_submit_Click(object sender, ImageClickEventArgs e)
{
string File = "~/CvFiles/" + FU_CV.FileName;
if (FU_CV.FileBytes.Length > 4194304)
{
modalpopup.Show();
}
}
I had solved this problem as I added TargetControlID to hidden field's ID but when I replaced it with the ID of submit button "BT_submit" it worked well.

#include file vs iframe or is there a better way [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
ok simple question about including large mostly static html and asp.net code I am using as of right now #include and I was wondering if iframes would be a better way of handling what I wish to do or is there a better way to do it. here is the current way i'm handling the includes
default.aspx
<%# Page Language="C#" AutoEventWireup="true" ValidateRequest="false" %>
<%# Import Namespace="YAF.Classes.Core" %>
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
btnSearch.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(btnSearch, "") + ";this.disabled = true;");
if (forum.PageUserID != 1)
{
Page.FindControl("divGuest").Visible = false;
Page.FindControl("divUser").Visible = true;
lblUserName.Text = forum.PageUserName;
}
else
{
Page.FindControl("divGuest").Visible = true;
Page.FindControl("divUser").Visible = false;
lblUserName.Text = null;
}
}
public void Page_Error(object sender, System.EventArgs e)
{
Exception x = Server.GetLastError();
YAF.Classes.Data.DB.eventlog_create(YafServices.InitializeDb.Initialized ? (int?)YafContext.Current.PageUserID : null, this, x);
YAF.Classes.Core.CreateMail.CreateLogEmail(x);
}
protected void btnSearch_Click(object sender, EventArgs e)
{
if (txtSearch.Text.Length > 4)
{
if(ddlCriteria.SelectedValue == "Posts")
Response.Redirect("default.aspx?g=search&search=" + txtSearch.Text);
if(ddlCriteria.SelectedValue == "Posted By")
Response.Redirect("default.aspx?g=search&postedby=" + txtSearch.Text);
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="YafHead" runat="server">
<meta id="YafMetaDescription" runat="server" name="description" content="Yet Another Forum.NET -- A bulletin board system written in ASP.NET" />
<meta id="YafMetaKeywords" runat="server" name="keywords" content="Yet Another Forum.net, Forum, ASP.NET, BB, Bulletin Board, opensource" />
<title>Forums</title>
<style type="text/css">
.sbutton
{
background-color:#361800;
border:medium none;
border-collapse:collapse;
color:#FFFFFF;
font-family:Tahoma,Arial,Helvetica;
font-size:10px;
font-weight:bold;
vertical-align:middle;
}
</style>
<link href="images/favicon.ico" type="image/ico" rel="shortcut icon" />
<link rel="stylesheet" href="navTopStyle.css" type="text/css" media="screen" />
</head>
<body style="margin: 0">
<form id="form1" runat="server" enctype="multipart/form-data">
<table align="center" style="background-color: #ffffff" cellpadding="0" cellspacing="0"
width="790px">
<tr>
<td>
<!--#include file="CComHeader.html"-->
</td>
</tr>
<tr>
<td>
<YAF:Forum runat="server" ID="forum"></YAF:Forum>
</td>
</tr>
</table>
</form>
</body>
</html>
CComHeader.html
<table cellpadding="0" cellspacing="0" width="790px">
<tr>
<td align="left">
<img src="images/smokechair.jpg" alt="Cigar.com" /><img src="images/cigarcomTitle.gif"
alt="Cigar.com" />
</td>
<td align="right">
<table width="310px" height="73px" cellpadding="0" cellspacing="0" style="padding-right: 6px">
<tr>
<td width="109px" class="welcome" align="left">
Welcome to Cigar.com
</td>
<td width="195px" class="welcome" align="left">
<div runat="server" id="divUser">
<table cellpadding="0" cellspacing="0" align="right">
<tr>
<td width="126px" align="left">
<asp:Label ID="lblUserName" CssClass="welcome" runat="server"></asp:Label></td>
<td width="65px" align="left">
Help</td>
</tr>
</table>
</div>
<div runat="server" id="divGuest">
Sign In | Join |
Help
</div>
</td>
</tr>
<tr>
<td colspan="2">
<table cellpadding="0" cellspacing="0" >
<tr>
<td width="234px" align="right">
<asp:DropDownList ID="ddlCriteria" runat="server">
<asp:ListItem>Posts</asp:ListItem>
<asp:ListItem>Posted By</asp:ListItem>
</asp:DropDownList>
<asp:TextBox Width="120px" ID="txtSearch" runat="server"></asp:TextBox>
</td>
<td width="70px" align="center">
<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="sbutton" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<!--#include file="commonTabBar.html" -->
</td>
</tr>
</table>
commonTabBar.html
<div class="CommonTabBar">
<script language="javascript">
function tabOver(e) {
if (e.className != 'CommonSimpleTabStripSelectedTab')
e.className = 'CommonSimpleTabStripTabHover';
}
function tabOut(e) {
if (e.className != 'CommonSimpleTabStripSelectedTab')
e.className = 'CommonSimpleTabStripTab';
}
function tabOverSub(e) {
if (e.className != 'CommonSimpleTabStripSelectedTabSub')
e.className = 'CommonSimpleTabStripTabHoverSub';
}
function tabOutSub(e) {
if (e.className != 'CommonSimpleTabStripSelectedTabSub')
e.className = 'CommonSimpleTabStripTabSub';
}
</script>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr valign="middle">
<td class="CommonSimpleTabStripTab" style="padding: 0px">
</td>
<td class="CommonSimpleTabStripTab" onmouseover="tabOver(this);" onmouseout="tabOut(this);"
onclick="window.location = 'http://www.cigar.com/index.asp'">
<a style="float: right; display: block; height: 30px; line-height: 30px; padding-left: 12px;
padding-right: 12px; vertical-align: middle;" href="http://www.cigar.com/index.asp">
Home</a>
</td>
<td class="CommonSimpleTabStripTab" onmouseover="tabOver(this); document.getElementById('ComDropDown2').style.display = 'inline';"
onmouseout="tabOut(this); document.getElementById('ComDropDown2').style.display = 'none';">
<a style="float: right; display: block; height: 30px; line-height: 30px; padding-left: 12px;
padding-right: 12px; vertical-align: middle;" href="http://www.cigar.com/cigars/index.asp">
Cigars</a>
<div id="ComDropDown2" style="border: 1px solid rgb(71, 42, 24); margin: 28px 0px 0px;
display: none; background-color: rgb(235, 230, 208); color: rgb(71, 42, 24);
position: absolute; float: left; z-index: 200;" onmouseover="document.getElementById('ComDropDown2').style.display = 'inline';"
onmouseout="document.getElementById('ComDropDown2').style.display = 'none';">
<ul style="margin: 0px; padding: 0px; width: 100px;">
<li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left;
list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); "
onclick="window.location = 'http://www.cigar.com/cigars/index.asp'"><a href="http://www.cigar.com/cigars/index.asp"
style="line-height: 25px; color: rgb(71, 42, 24);" id="BrandsLink">Brands </a>
</li>
<li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left;
list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); "
onclick="window.location = 'http://www.cigar.com/cigars/privatelabel.asp?brand=419'">
<a href="http://www.cigar.com/cigars/privatelabel.asp?brand=419" style="line-height: 25px;
color: rgb(71, 42, 24);" id="SamplersLink">Aging Room </a></li>
<li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left;
list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); "
onclick="window.location = 'http://www.cigar.com/cigars/samplers.asp'"><a href="http://www.cigar.com/cigars/samplers.asp"
style="line-height: 25px; color: rgb(71, 42, 24);" id="SamplersLink">Samplers
</a></li>
<li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left;
list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); "
onclick="window.location = 'http://www.cigar.com/cigars/suggestions.asp'"><a href="http://www.cigar.com/cigars/suggestions.asp"
style="line-height: 25px; color: rgb(71, 42, 24);" id="SuggestionsLink">Suggestions
</a></li>
<li class="CommonSimpleTabStripTabSub" style="margin: 0px; padding: 3px; text-align: left;
list-style: none outside none;" onmouseover="tabOverSub(this); " onmouseout="tabOutSub(this); "
onclick="window.location = 'http://www.cigar.com/DailyDeal/ccCigarDeals.asp'"><a
href="http://www.cigar.com/DailyDeal/ccCigarDeals.asp" style="line-height: 25px;
color: rgb(71, 42, 24);" id="SuggestionsLink">Suggestions </a></li>
</ul>
</div>
Redid the example I was trying to make this into a UC but I ran into a problem with the server script and it not allowing me to obfuscate it more.
There's no reason to use IFRAMEs in this scenario. Their disadvantages are:
They are fixed in size
They don't count for the SEO on your page
You can't access the DOM for items in them (to do scripting)
So I would "include" a file. With ASP.NET your best bet is User Controls or Master Pages.
Using an iframe will cause the client browser to make another HTTP request in order to retrieve its contents. Unless you have a really specific need (like sticking your code into someone else's website) you probably never want to use an iframe.
I don't really see the point of iframes, but I'm open to suggestion. If you need dynamic content, you can use AJAX and normal divs. If your server for some reason needs to include content from another domain or server, you can use curl.

Resources