I am having a real struggle trying to accomplish something for work.
I have a starting page with a textbox and a button. I want to be able to post the value entered in the textbox to an iframe, but the iframe is on another another web page called iframeholder.
I am not allowed to session variables or querystring. It has to be post.
I want to send the value of TextBox_Link to the iframe and be able to store it as the value of a ListItem in the RadioButtonList. I greatly appreciate any feedback.
Starting Page
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td><asp:TextBox ID="TextBox_Link" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="Button_Post" runat="server" Text="Button" /></td>
</tr>
</table>
</div>
</form>
iframeholder page
<body>
<form id="form1" runat="server">
<div>
<iframe src ="iframe.aspx" name="iframe" width="100%" height="300">
</div
</form>
</body>
iframe
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>Link1</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
</div>
</form>
</body>
Try adding target='iframe' in your <form> tag.
Related
So, I know you can only have 1 runat="server" and <form> per master page. My question is, how do I put my login FORM on my website? Do I put it all on the master page? Or some on the page and some on the .aspx form? Right now I have it mostly on Master, and the onClick() event on the .aspx page. I'll postcode at the below.
My Login.ASPX page.
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="navbar">
Login
</div>
<p style="text-align: center">WELCOME HOME</p>
</asp:Content>
Here is my Master page code
<head runat="server">
<link href="CSS/StyleCSS.css" rel="stylesheet" />
<title>11</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div class="header">
<h1> 11MO</h1>
</div>
<div class="PopupPosition">
<div class="form-popup" id="myForm">
<form class="form-container" id="form1" runat="server">
<h1>Login Form</h1>
<p style="text-align: center">Please login using your <strong><em>User ID and Password</em></strong></p>
<asp:Label ID="lblUserName" runat="server" Text="User Name:"> </asp:Label>
<asp:TextBox ID="txtUserName" runat="server"> </asp:TextBox>
<asp:Label ID="lblPassword" runat="server" Text="Password:"> </asp:Label>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"> </asp:TextBox>
<asp:Button ID="btnLogin" runat="server" Width="315px" CssClass="btn" OnClick="btnLogin_Click" Text="Login"></asp:Button>
<button type="button" class="btn cancel" onclick="closeForm()">Close</button>
</form>
</div>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<footer class="Footer">
<p>© 2020 - Application Homepage</p>
</footer>
</body>
</html>
<script>
function openForm() {
document.getElementById("myForm").style.display = "block";
}
function closeForm() {
document.getElementById("myForm").style.display = "none";
}
</script>
RESULT I would like to get the code all on 1 page, be it master or login. I've tried putting it all in the ContentPlaceHolder1 area and it doesn't work. I think it's because I have 2 server run operations when I do that. So, how do I get it all on 1 page, but still keep the format for my other pages available. I also have Tiles that I want to be transferred so I'll haft to keep that on the master. Will I haft to add a sub Master page?
you can use the article to create login form using master pages
https://www.c-sharpcorner.com/UploadFile/009464/simple-login-form-in-Asp-Net-using-C-Sharp/
i'm building a site for course project in Web forms asp.net
and i did a master page for all the website
i want to have a text box that acts as a search in the website
but it needs to be in
<form runat="server">
this is master code
<html>
<div id="topContent">
<head runat="server">
<form runat="server">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
<title>Dor Lugasi Guitar Shop</title>
<link href="Styles.css" rel="stylesheet" type="text/css" />
<right>
<img src="../Images/logobk2.png" alt="Powered by DLG!" class="auto-style7"/><br />
<center id="headdiv">
<asp:LinkButton ID="lnkHome" runat="server" PostBackUrl="~/Pages/Home.aspx" >Home</asp:LinkButton>
<asp:LinkButton ID="lnkLogin" runat="server" PostBackUrl="~/Pages/Login.aspx">Login</asp:LinkButton>
<asp:LinkButton ID="lnkContact" runat="server" PostBackUrl="~/Pages/Contact.aspx" >Contact</asp:LinkButton>
<asp:LinkButton ID="lnkGuitarLab" runat="server" PostBackUrl="~/Pages/GuitarLab.aspx">Guitar Lab</asp:LinkButton>
<asp:ImageButton style="float:left;margin-left:10px;" ID="btnCart" runat="server" Height="55px" ImageUrl="~/Images/cart.png" Width="55px" PostBackUrl="~/Pages/Cart.aspx" />
<asp:TextBox ID="txtSearch" runat="server" BackColor="Silver" BorderColor="Black" TextMode="Search" placeholder=" Search" onkeypress="txtSearch"></asp:TextBox>
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl="~/Images/src.png" OnClick="btnSearch_Click" Width="25px" />
</center>
<center id="headdiv" class="auto-style6">
<asp:Label style="float:left;margin-left:10px;" ID="lblLoggedUser" runat="server" Font-Bold="True" Font-Size="Large" ForeColor="Red"></asp:Label>
<asp:LinkButton ID="btnLogOut" runat="server" OnClick="btnLogOut_Click" Visible="False" CssClass="auto-style5" Height="24px" Width="99px">Log Out</asp:LinkButton>
<asp:LinkButton style="float:right;margin-right:10px;" ID="lnkManageProducts" runat="server" PostBackUrl="~/Pages/ManageProducts.aspx">Manage Products</asp:LinkButton>
<asp:LinkButton style="float:right;margin-right:10px;" ID="lnkManageUsers" runat="server" PostBackUrl="~/Pages/ManageUsers.aspx">Manage Users</asp:LinkButton>
</center>
</form>
</head>
</div>
<body id="body">
<form runat="server">
<center>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</center>
<footer id="footer" class="auto-style3">
</left>
<img src="../Images/logowhite.png" alt="Powered by ASP.NET!" />
</footer>
</form>
</body>
</html>
but im getting a:
A page can have only one server-side Form tag.
before i added this search textbox and button i had
<form runat="server">
<html>
...
<head>.....</head>
<body>....</body>
<footer>.....</footer>
</html>
</form>
and it worked
but at the login page when i pressed Enter it applied to the search form instead of the login form
eventually i ended up making a single form for the page and just put the specific form that had buttons in
<asp:Panel ID="search_panel" runat="server" DefaultButton="btnSearch">
<asp:TextBox ID="txtSearch" runat="server" BackColor="Silver" BorderColor="Black" TextMode="Search" placeholder=" Search" onkeypress="txtSearch"></asp:TextBox>
<asp:ImageButton ID="btnSearch" runat="server" ImageUrl="~/Images/src.png" OnClick="btnSearch_Click" Width="25px" />
</asp:Panel>
i hope thats the right way
So previously my login worked fine. And then I made some edits and it stopped working. Here are the edits I made to my website in between it going from working to not working.
I was trying to make a submit content page but I kept getting errors about not being able to contain a form inside a form. So I went over to my master page and removed the form tag and then added all the form tags I needed into each individual page. In the end I ended up removing all form tags and putting a single form tag around the content place holder in the master page.
I added a new table to my SQL database to store content submitted by users. I use Microsoft Server Express for my database.
The error I am getting is not an error in my console, it is just that my PostBackURL is loaded with out anything happen. Even if I enter a correct login (I have checked and the login info I tested is stored in my database), it will just automatically load the PostBackURL with no login occuring, nor any Login failed messages.
Web Config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<authentication mode="Forms">
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
Master Page (Relevant Parts):
<body>
<form id="form1" runat="server">
<div class="header headerLogin">
<img style="margin-left: 5vw; margin-top: 5px; height: 32px; width: 130px;" src="images/inshortlogo.png" />
<p class="taskbarLinks">
HOME
NEWS
JOB LISTINGS
STUDY
LOGIN
</p>
<script>
...
</script>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
Login Page:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="Absolute-Center">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">Log In</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="ctl08$Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ctl08$Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" CssClass="button" PostBackUrl="~/home.aspx" Text="Log In" ValidationGroup="ctl08$Login1" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
<br />
<div style="text-align: center;">
<a class="button" style="margin-right: 2em;" href="signup.aspx">Register</a>
<a class="button" href="forgotpassword.aspx">Forgot Password</a>
</div>
</AnonymousTemplate>
<LoggedInTemplate>
<asp:Label ID="logOutLabel" runat="server" Text=""></asp:Label>
<br />
<br />
<div style="text-align: center;">
<asp:LinkButton ID="logOutButton" runat="server" class="button" OnClick="logOutButton_Click">Log Out</asp:LinkButton>
</div>
</LoggedInTemplate>
</asp:LoginView>
</div>
<style>
.Absolute-Center {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
</style>
</asp:Content>
Thanks in advance!
Remove the postbackurl. That posts the form to another page, so of course you don't get logged in. Instead, upon successful login, perform a redirect to whatever page you want.
I want to have a tree view on the left side of the screen along with a multiview which displays the content of the selected tree item on the right side of the screen. My problem is that I cannot seem to align the multiview such that it is to the right of the tree view. Its stuck to the bottom of the treeview. Here's a simplified version of what I have.
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode Text="1" Value="1">
<asp:TreeNode Text="1.1" Value="1.1"></asp:TreeNode>
<asp:TreeNode Text="1.2" Value="1.2"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="2" Value="2"></asp:TreeNode>
</Nodes>
</asp:TreeView>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<asp:Label ID="Label1" runat="server" Text="something here"></asp:Label>
</asp:View>
</asp:MultiView>
</div>
</form>
</body>
How do I align it to the right?
put both inside two div's and use css-style float:left for the first and float:right for the second with width it will work.
<body>
<form id="form1" runat="server">
<div style="float:left;width:200px;">
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode Text="1" Value="1">
<asp:TreeNode Text="1.1" Value="1.1"></asp:TreeNode>
<asp:TreeNode Text="1.2" Value="1.2"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="2" Value="2"></asp:TreeNode>
</Nodes>
</asp:TreeView>
</div>
<div style="float:right; width:800px;">
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<asp:Label ID="Label1" runat="server" Text="something here"></asp:Label>
</asp:View>
</asp:MultiView>
</div>
</form>
</body>
For the sake of simplicity...you can wrap them both (treeview and multiview) inside a div. Then you can style the divs to dipplay inline-block...That'll give you the results you want
Hope it helps
leo
I am doing a tutorial that uses the mvc. I have the following view:
Index.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MovieApp.Models.Movie>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2>
<form action="Movie/List" method="post">
<table>
<tr>
<td>
<button id="List" type="button" onclick="">List</button>
</td>
</tr>
</table>
</form>
<form action="Create.aspx" method="post">
<table>
<tr>
<td>
<input type="submit" value="Create" />
</td>
</tr>
</table>
</form>
</asp:Content>
so when you click on create it must call the Create view.
when i run the app i get an error: Resource cannot be found. Create.aspx a view in the movie folder.
What is the path that I need to specify for the Create.aspx to be found?
You shouldn't be pointing to the page, Create.aspx. You should be pointing to a method called Create in a controller.
Its not clear on any controller you are using, but by default it will post to its own controller (with the same name). Or you can specify the method and controller to post to like this, using Html.BeginFrom:
#using (Html.BeginForm("Method", "Controller", FormMethod.Post))
{
<table>
<tr>
<td>
<input type="submit" value="Create" />
</td>
</tr>
</table>
}