ASP.Net form in master page an on a child page - asp.net

I have defined a MasterPage in ASP web project. There I have a top bar with a search field:
<div class="top-bar">
<asp:ContentPlaceHolder ID="ContentPlaceHolder_header" runat="server">
<div class="header search">
<asp:TextBox ID="txtSearch" runat="server" />
</div>
</asp:ContentPlaceHolder>
</div>
<!-- Body content. -->
<div id="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder_BodyContent" runat="server" />
</div>
On a separate field, I have a login form:
<asp:Content ID="Content1" ContentPlaceHolderID = "ContentPlaceHolder_BodyContent"
runat="server">
<form id="AuthenticationForm" class="login-register-form" method="POST" runat="server">
</form>
</asp:Content>
The problem is that I need a form at the login page, but I want to show it inside the body placeholder.
I'm getting the error that asp:TextBox should be inside a form, but as far as I know, it's not possible to have multiple forms in the same page at the same time in ASP.

ASP.Net WebForms is designed to only have one form per page, so remove the form tags from the login page and make sure the master page has all controls inside the form tags:
<form>
<div class="top-bar">
<asp:ContentPlaceHolder ID="ContentPlaceHolder_header" runat="server">
<div class="header search">
<asp:TextBox ID="txtSearch" runat="server" />
</div>
</asp:ContentPlaceHolder>
</div>
<!-- Body content. -->
<div id="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder_BodyContent" runat="server" />
</div>
</form>

Related

On postback css setting deleted from masterpage

I saw several post similar to mine but couldn't find a solution that fits my issue (the masterpage issue :) ).
I have a masterpage with side menu , that I created with a list (ul > li).
Whenever I select a li which refers to nowhere("ftq" for example) - the function works great and changes the css setting as I want.
But, whenever I select a li which refer to a "real" page ("updateinspec.aspx" for example) and there's a postback, all the CSS is gone .
here's the code - any help will be great
<%# Master Language="VB" AutoEventWireup="false" CodeBehind="MasterVC.master.vb" Inherits="HangarApp.MasterVC" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="MasterCSS.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
function myFunction(x) {
x.classList.toggle("change");
}
var lst;
function cngclass(obj) {
if (lst) lst.className = '';
obj.className = 'listactive';
lst = obj;
}
</script>
<asp:ContentPlaceHolder ID="headtitlePH" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="topcontent">
<div class="menudiv" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
<div class="divtitle">
<img src="../images/logo1.png" />
<asp:Label runat="server" ID="userlbl" style="padding:12%;"></asp:Label>
</div>
</div>
<div id="subtopdiv">
<div id="sub_inspec">
<br />
<asp:Label ID="stationname" runat="server" CssClass="subtopdiv"></asp:Label>
<asp:Label ID="stationcode" runat="server" Visible="false" ></asp:Label>
<asp:Label ID="linecode" runat="server" Visible="false"></asp:Label>
<asp:Label ID="typecode" runat="server" Visible="false"></asp:Label>
<asp:Label ID="lblinspecnum" runat="server" Visible="false"></asp:Label>
</div>
</div>
<div id="maincontent">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<h1></h1>
<div class="innerdiv" id="divlefttop">
<asp:ContentPlaceHolder ID="divlefttopPH" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="innerdivdtop" id="divrighttop" runat="server">
<asp:ContentPlaceHolder ID="divrighttopPH" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="innerdivld" id="divleftdown" runat="server">
<asp:ContentPlaceHolder ID="divleftdownPH" runat="server" >
</asp:ContentPlaceHolder>
</div>
<div class="innerdivd" id="divrightdown">
<asp:ContentPlaceHolder ID="divrightdownPH" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
<div id="leftcontent">
<div id="menuinsp" runat="server">
<ul>
<li><a onclick="cngclass(this);" class="active" href="Inspec_Main.aspx">Inspection APP</a></li>
<li><a onclick="cngclass(this);" class="nactive" href="#ftqpage">FTQ</a></li>
<li><a onclick="cngclass(this);" class="nactive" href="#managepage">MANAGE</a></li>
<li><a onclick="cngclass(this);" class="nactive" href="UpdateInspec.aspx">UPDATE</a></li>
<li><a onclick="cngclass(this);" class="nactive" href="#about">ABOUT</a></li>
</ul>
</div>
</div>
<div id="footercontent">
<label>LAHAV IT SYSTEM - DANA B COHEN - TEL:58840</label>
</div>
<asp:ContentPlaceHolder ID="footertitlePH" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
I think your master page isn't in the same directory as the aspx pages and you didn't use correct href in below link:
<link href="MasterCSS.css" type="text/css" rel="stylesheet" />
You need use server side link like this.
Modify your Mastercss.css link as given below and let us know if problem still exist.
<link href="/MasterCSS.css" type="text/css" rel="stylesheet" />

ASP.NET simple image display

I have a simple problem where the image(stored in the website's root folder), is being displayed in visual studio's design view but not when i run it in the browser.
Following is my code.
the text portion is not getting displayed either.
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<div>
<h2 style="color:gray; text-align: center;">
<br />
<asp:Image ID="Image1" runat="server" AlternateText="placement portal logo" Height="100px" ImageUrl="~/1369497013.png" Width="100px" ImageAlign="AbsMiddle" />
<br /> Placement<br />
Cell
</h2>
</div>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
3 ways
1-use CSS to give path but this will not work in your case
2-use html to give path harrdcoded thing always works there
3-use c# to give path and remember to
give path accurratly using
../root/image1.png
or
~/root/image1.png

What is meant by bootstrapping a page? Converting aspx to bootstrap?

I have the task of modifying some already developed web app's aspx pages. Those pages Needs to be converted to use the new Bootstrap layout. So what is meant by bootstrapping page? one of the pages is below. Please give me some idea.
<%# Page Language="VB" MasterPageFile="~/MasterExternal.master" AutoEventWireup="false" CodeFile="OptIt.aspx.vb" Inherits="OptIt" %>
<%# MasterType VirtualPath="~/MasterExternal.master" %>
<asp:Content ID="c2" ContentPlaceHolderID="cpStyle" Runat="Server">
<style type="text/css">
#middleContentContentParent {position:relative;left:50px;width:900px;}
.dtText {font-size:22px;height:35px;line-height:35px;width:50px}
input[type=text] {padding:0;}
</style>
</asp:Content>
<asp:Content ID="c3" ContentPlaceHolderID="cp3" Runat="Server">
<form runat="server" id="aspnet">
<div style="position:relative;width:860px;height:450px;margin:0 20px 0 20px">
<h1>Opt-In to TXT Messaging</h1>
<hr />
<div style="text-align:left;" >
<div runat="server" id="divFields">
<p>
Enter your cell phone noted in the email you just received to receive your TXT confirmation. Then follow the directions in the TXT message.
</p>
<br />
<div style="width:360px;margin:0 auto;text-align:center">
<asp:ValidationSummary class="valSummaryLg" ID="valSummary" runat="server" />
<h4>Mobile Number</h4>
<p style="text-align:left">
(<input runat="server" type="text" size="3" class="dtText" maxlength="3" id="CellPhone1_1" value="" /> ) <input class="dtText" runat="server" type="text" maxlength="3" size="3" id="CellPhone1_2" value="" /> - <input runat="server" type="text" maxlength="4" size="4" id="CellPhone1_3" class="dtText" value="" />
<asp:CustomValidator runat="server" ID="valPhone" Text="*"></asp:CustomValidator>
<br />
<br />
<asp:Button runat="server" CssClass="button1Lg" ID="btnSubmit" Text="Submit" />
</p>
</div>
</div>
<div runat="server" id="lblMessage" visible="false">
<br /><br />
<h2>Almost done... </h2>
<p>
Follow the instructions in the TXT you just received. If you don't receive a TXT confirmation message, please see the "Commons Problems" below.
</p>
<br /><br />
<h4>Common Problems with TXTing (using SHORT CODES):</h4>
<p>
FFPS uses a 5 digit "short code" to send TXT messages. Short codes are used for businesses to ensure the sender is respecting the recipient's TXTing preferences. Some carriers (like Sprint) require individuals to call and UNBLOCK SHORT CODES. Some of the common problems with receiving FFPS TXT messages include:
</p>
<div style="margin:0 0 0 20px">
<h5>You are using Wal-Mart Family Mobile</h5>
<p><b>How to Fix:</b> Sorry, Wal-Mart does not support TXTing with Short Codes</p>
<h5>You are using Sprint and they have blocked Short Codes</h5>
<p><b>How to Fix:</b> Call Sprint and request to "Unblock Short Codes"</p>
</div>
</div>
</div>
</div>
</form>
</asp:Content>
This is an answer for my own question. I have changed this to use bootstrap. I have added row classes for every row. Please have a look and give some ideas.
<%# Page Language="VB" MasterPageFile="~/MasterExternal.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Scholarship_Default" %>
<%# MasterType VirtualPath="~/MasterExternal.master" %>
<asp:Content ID="c2" ContentPlaceHolderID="cpStyle" Runat="Server">
<%--<style type="text/css">
#middleContentContentParent {position:relative;left:50px;width:860px;}
#divDownloadForms img {vertical-align:middle}
</style>--%>
</asp:Content>
<asp:Content ID="c3" ContentPlaceHolderID="cp2" Runat="Server">
<%--<div style="position:relative;width:820px;height:400px;margin:0 auto;">--%>
<div>
<div class="row">
<h1>Scholarship Form</h1>
</div>
<div class="row">
<h2>Instructions</h2>
</div>
<div class="row">
In order to apply for a scholarship, you will need to complete the Scholarship/Signup forms. Please mail the 4 page form by the deadline stated below (otherwise, may cause delays or prevent placement). Detailed instructions and the mailing address are found on the form (link below).<br />
</div>
<div class="row">
<h2>Form Deadline</h2>
</div>
<div id="divDownloadForms">
<div class="row">
For
<b><asp:Label runat="server" ID="lblSeason"></asp:Label></b>,
FFPS must receive your scholarship form by <b><asp:Label runat="server" ID="lblDate"></asp:Label></b>.
</div>
<div class="row">
<h5>Download the Scholarship/Signup Form - High Resolution (pdf)</h5>
</div>
<div class="row">
<img src="../images/icons/attach.gif" alt="" /> Download File
</div>
</div>
</div>
</asp:Content>
Sham, If you can show the existing design, then I can help you. You need to add column grid in between row's for suitably viewing in all view-ports.

Get user control element text from aspx page in asp.net

I want to get text value of my label from user control in my aspx page to make it null.How to I access that . I tried that but this is not working
I have a pane in which user control is present
<%# Register Src="~/General/Setup/UserControl/Branch.ascx" TagName="Branch" TagPrefix="uc1" %>
<asp:Panel ID="pnlBranchAdd" runat="server" Width="60%">
<div class="lgbx">
<div class="bx_bor">
<div id="divClose" align="right" style="height: 6px;z-index:-1;" >
<asp:ImageButton runat="server" ID="Close" ImageUrl="../../Images/icn_close2.png"
CssClass=style3 onclick="Close_Click" Height="34px" Width="36px" />
</div>
<div class="content">
<h2>
<strong>Branch</strong></h2>
<uc1:Branch ID="Branch" runat="server" />
</div>
</div>
</div>
</asp:Panel>
Need help
thanks.
Hope this work
Label lbl = (Label)Branch.FindControl("LabelID");

Applying a Dojo Toolkit (Dijit) theme to ASP.NET pages

In the code below, I am trying to apply a Dijit theme to the controls in my .aspx page. However, the controls persist in their normal, unthemed appearance.
Anybody know why?
Master Page:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="Main.master.cs" Inherits="WebJournalEntryClient.Main" %>
<!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>My Web Application</title>
<link rel="stylesheet" href="dojoroot/dijit/themes/tundra/tundra.css" />
<script type="text/javascript" src="dojoroot/dojo/dojo.js"/>
<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.ComboBox");
</script>
</head>
<body class = "tundra">
<form id="form1" runat="server">
<div>
<div>
This is potentially space for a header bar.
</div>
<table>
<tr>
<td>
Maybe <br /> a <br /> Side <br /> bar.
</td>
<td>
<asp:ContentPlaceHolder ID="CenterPlaceHolder" runat="server"/>
</td>
</tr>
</table>
<div>
This is potentially space for a footer bar.
</div>
</div>
</form>
</body>
</html>
Content Page:
<%# Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="LogIn.aspx.cs" Inherits="WebJournalEntryClient.LogIn" %>
<asp:Content ID="Content" ContentPlaceHolderID="CenterPlaceHolder" runat="server">
<div>
User ID: <asp:TextBox ID = "UserName" dojoType="dijit.form.TextBox" runat="server" /><br />
Password: <asp:TextBox ID = "PassWord" dojoType="dijit.form.TextBox" runat="server" /><br />
<asp:Button ID="LogInButton" Text="Log In" dojoType="dijit.form.Button" runat="server" />
</div>
</asp:Content>
You need to add djConfig="parseOnLoad: true" to you script tag.
<script type="text/javascript" src="dojoroot/dojo/dojo.js" djConfig="parseOnLoad: true"/>
Or
dojo.parser.parse();
Could be the path is wrong. Use Firebug to see if it's reading any css.
I am not sure about what ASP.net is doing with your page.
However in any case can you double check with firebug wheather your body has "tundra" class in the Browser Output ?? I am assuming that the CSS is comming properly (: as you mentioned in above comment)

Resources