I have one page with masterpage as 'checkout.aspx' with asp button in bottom
<%# Page Title="" Language="C#" MasterPageFile="~/allpage.Master" AutoEventWireup="true" CodeBehind="checkout.aspx.cs" Inherits="CafeSite.checkout" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
B Cafe Checkout
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="body" runat="server">
<br>
<form id="form1" runat="server" action="submit.aspx">
<div style="text-align:center;">
<p style="color:orangered;font-family:'B Koodak';">
<span style="color:white;">آقا/خانم:</span>
<input type="hidden" name="last-form-name" value="<% =Page.Request.Params["last-form-name"] %>" /> <% =Page.Request.Params["last-form-name"] %>
</p>
<p style="color:orangered;font-family:'B Koodak';">
<span style="color:white;">به شماره موبایل:</span>
<input type="hidden" name="last-form-phone" value="<% =Page.Request.Params["last-form-phone"] %>" /> <% =Page.Request.Params["last-form-phone"] %>
<span style="color:white;">به شماره میز:</span>
<input type="hidden" name="last-form-sellist" value="<% =Page.Request.Params["last-form-sellist"] %>" /> <% =Page.Request.Params["last-form-sellist"] %>
</p>
<input type="hidden" name="order" value="<% =Page.Request.Params["order"] %>" />
<input type="hidden" name="count" value="<% =Page.Request.Params["count"] %>" />
</div>
<p id="P-Header">
سفارشات شما
به شرح ذیل می باشد
</p>
<div class="text-center">
<div class="text-center">
<div id="Table-Div" class="container" >
<asp:Table ID="Table1" runat="server" Height="100%" Width="100%">
</asp:Table>
</div>
</div>
<br>
<asp:Button ID="Button1" runat="server" form="form1" CssClass="btn-success rounded" Text="مورد تایید است" PostBackUrl="~/submit.aspx" />
</div>
</form>
<br>
</asp:Content>
my asp button has postbackurl to my submit page but is not working
I don't know how to solve this proble. does anyone know how to solve this and help me?
Add the form to the master page not the subpage just after the body.
Something like
<body>
<form runat="server" id="myformID" enctype="multipart/form-data">
Then just add a button to the sub-page and wire it up like normal in the code behind
I found the answer of my question.
In the aspx page with master page the form id is change and so here we should edit form properties on asp button from form1 to aspnetForm.
<asp:Button ID="Button1" runat="server" form="aspnetForm" CssClass="btn-success rounded" Text="مورد تایید است" PostBackUrl="~/submit.aspx" />
Related
I tried to put an update panel in my aspx form, but it keeps on showing this error. The ScriptManager must appear before any controls that need it
This is my aspx
<form id="Form1" runat="server" class="form-horizontal">
<div class="col-lg-6">
<%--<asp:Panel id="pnlExisting" runat="server">
<div class="alert alert-danger" role="danger">
<i class="glyphicon glyphicon-exclamation-sign"></i> <asp:Label ID="recordCheck" runat ="server"> </asp:Label>
</div>
</asp:Panel>--%>
<div class="form-group">
<label class="control-label col-lg-4">Project</label>
<div class="col-lg-8">
<asp:DropDownList ID="ddlProjects" runat="server" class="form-control" AutoPostBack="true"
onselectedindexchanged="ddlProjects_SelectedIndexChanged" /><br />
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-4">Project Code</label>
<div class="col-lg-8">
<asp:Textbox ID="txtProjectCode" runat="server" class="form-control" required />
</div>
</div>
<%-- <div class="form-group">
<label class="control-label col-lg-4">Price</label>
<div class="col-lg-8">
<asp:Textbox ID="txtPrice" runat="server" class="form-control" Textmode="Number" required />
</div>
</div>--%>
<%-- <div class="form-group">
<label class="control-label col-lg-4">Status</label>
<div class="col-lg-8">
<asp:Textbox ID="txtStatus" runat="server" class="form-control" required />
</div>
</div>--%>
</div>
<asp:UpdatePanel ID="upMaterialsList" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lvMaterialsList" EventName="PagePropertiesChanging" />
</Triggers>
<ContentTemplate>
<table class="table table-hover">
<thead>
<th>Material</th>
<th>Quantity</th>
<th>Status</th>
<th>Date Added</th>
<th>Date Modified</th>
<th></th>
</thead>
<tbody>
<asp:ListView ID="lvMaterialsList" runat="server" ondatabound="lvMaterialsList_DataBound"
onpagepropertieschanging="lvMaterialsList_PagePropertiesChanging" OnItemCommand="lvMaterialsList_ItemCommand">
<ItemTemplate>
<tr>
<td><%# Eval("SupplierProduct")%></td>
<td><%# Eval("Quantity") %></td>
<td><%# Eval("Status") %></td>
<td><%# Eval("DateAdded", "{0: MMMM dd, yyyy}") %></td>
<td><%# Eval("DateModified", "{0: MMMM dd, yyyy}") %></td>
<td>
<asp:Label ID="ltReqMat" runat="server" Text='<%# Eval("ReqMatID") %>' Visible="false" />
</td>
<td>
<asp:LinkButton Text="Approved" class="btn btn-success " ID="lbtnApproved" runat="server"
CommandName="Approve" > </asp:LinkButton>
<asp:LinkButton Text="Decline" class="btn btn-warning " ID="lbtnDecline" runat="server"
CommandName="Decline" > </asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<tr>
<td colspan="12"><h2 class="text-center">No records found.</h2></td>
</td>
</tr>
</EmptyDataTemplate>
</asp:ListView>
</tbody>
</table>
<div class="col-lg-12">
<center>
<asp:Button ID="btnReturn" runat="server" class="btn btn-default" Text="Back"
PostBackUrl="Default.aspx" formnovalidate />
</center>
</div>
<br />
<center>
<asp:DataPager ID="dpMaterialsList" runat="server" PageSize="10" PagedControlID="lvMaterialsList">
<Fields>
<asp:NumericPagerField ButtonType="Button"
NumericButtonCssClass="btn btn-default"
CurrentPageLabelCssClass="btn btn-success"
NextPreviousButtonCssClass="btn btn-default" />
</Fields>
</asp:DataPager>
</center>
</ContentTemplate>
</asp:UpdatePanel>
</form>
I want to know why it is not working properly
Add ScriptManager tags just below the <Form> tag of your page.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
You have to include the ScriptManager control in either your content page or Master page to enable ASP.NET AJAX features. So in your Master page you can place this control just after the form tag and ensure you put it before any ContentPlaceHolder control:-
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
By this all the content page which have the Master page set to the above master will automatically use this ScriptManager.
Apart from this, if at all you want to include any specific script reference in any of your content page then you can make use of ScriptManagerProxy control which at run time will combine the properties of both ScriptManager and ScriptManagerProxy.
According to ASP.NET AJAX:-
ScriptManager - A server control that makes script resources available
to the browser, including the Microsoft AJAX Library and the
functionality that enables partial-page rendering.
ScriptManagerProxy - A server control that enables nested components
to add script and service references if the page already contains a
ScriptManager control.
I want to call another ASP Page and pass a parameter (entry.ID).
I have a Master-Page Global.master like this (I will only post a part of code):
<body>
<div id="global" style="height:2000px;">
<form runat="server" id="globalForm">
<div id="body">
<asp:ContentPlaceHolder ID="mainContentPlaceHolder" runat="server">
<div id="mainContent">
</div>
</asp:ContentPlaceHolder>
</div>
</form>
</div>
and a Default.aspx Page which uses the Master-Page:
<asp:Content ID="Content1" ContentPlaceHolderID="mainContentPlaceHolder" runat="Server">
<div id="mainContent">
<% ICollection<Database.Blogentry> entries;
entries = Database.BlogentryDBO.Instance.getAllBlogentries();
foreach (Database.Blogentry entry in entries) { %>
<div class="blogEntryBody">
<div class="blogEntryText">
<%= entry.Content %>
</div>
</div>
<div class="blogEntryFooter">
<span class="blogEntryView">
<%--CALL HERE ANOTHER PAGE WITH A BUTTON AND PASS THE PARAMETER entry.ID-->
</span>
</div>
<%
}
%>
</div>
I already tried it with
<label visible="false" id="LabelEntryId" name="LabelEntryId"><%= entry.ID %></label>
<asp:button ID="Button2" runat="server" class="buttonBlogEntry" text="view more ..." onclick="viewEntireBlog_onclick" CommandArgument='<%# Eval("LabelEntryId")%>' />
but I don't have a CommandEventArgs element in the onClick method but only a EventArgs element so I can't access my CommandArgument?!
And using
<input runat="server" type="text" id="LabelEntryId" value="<%= entry.ID %>" visible="false"/>
and then accessing the input-element in the code-behind isn't possible either, because i have more than one LabelEntryId-Input because of the loop.
Another idea was to do something like this
<asp:button ID="Button1" runat="server" class="buttonBlogEntry" text="view more ..." onclick="<%= Response.Redirect("BlogEntrySortedByCategory.aspx?entryID=" + entry.ID); %>"/>
but I don't know how to do that...
Can you help me please?
have you tried with a standard a tag?
<a href='/someotherpage.aspx?entryid=<%= entry.Id %>'>View more</a>
I had my code to insert values into DB and after the data inserted the
ModalPopupExtender show and when click on OK button event fire to
reload the page . but I don't want all paged reload I tried to use
update panel but the OK event doesn't work .
<asp:Panel ID="PostPanel" runat="server" Style="display: none;">
<div class="modalPopup">
<div class="PopupBody">
<p class="ads-text">
GO </p>
</div>
<div class="Controls">
<div class="post">
<asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
OnClick="btnOkay_Click" />
</div>
</div>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModelExtenderPost" OkControlID="btnOkay" runat="server"
TargetControlID="HiddenField22" PopupControlID="PostPanel" PopupDragHandleControlID="PopupHeader"
Drag="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:HiddenField ID="HiddenField22" runat="server" />
protected void btnOkay_Click(object sender, EventArgs e)
{
Response.Redirect(Request.Url.ToString(), true);
}
use updatepanel that is in asp.net
in top of your page :
<%# Page Title="" Language="C#" MasterPageFile="~/..." EnableEventValidation="false" AutoEventWireup="true" ....
and for ypur panel:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode= "Conditional">
<ContentTemplate>
<div class="modalPopup">
<div class="PopupBody">
<p class="ads-text">
GO </p>
</div>
<div class="Controls">
<div class="post">
<asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
OnClick="btnOkay_Click" />
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnOkay" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
I want to make a function to register a new user without using CreateUserWizard. How could I change my code to allow this?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="registerUser.aspx.cs" Inherits="_Default" %>
<html>
<head runat="server">
<title>LLLY网上书店 - 注册</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<section class="register">
<h1>LLLY网上书店 - 注册新用户</h1>
<form method="post" action="index.html" runat="server">
<div class="reg_section personal_info">
<h3>个人信息</h3>
<asp:TextBox ID="username" runat="server" value="" placeholder="用户名"></asp:TextBox>
<asp:TextBox ID="email" runat="server" placeholder="电子邮件地址"></asp:TextBox>
</div>
<div class="reg_section password">
<h3>用户密码</h3>
<asp:TextBox ID="password" runat="server" placeholder="请输入密码"></asp:TextBox>
<asp:TextBox ID="confirmPwd" runat="server" placeholder="确认密码"></asp:TextBox>
<input type="password" name="confirm" value="" placeholder="确认密码">--%>
</div>
<div class="reg_section password">
<h3>地区</h3>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="textarea" runat="server" TextMode="MultiLine" placeholder="家庭住址"></asp:TextBox>
</div>
<p class="terms">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
我同意 LLLY网上书店 注册准入原则
</label>
</p>
<p class="submit">
<asp:Button ID="commit" runat="server" Text="注册" onclick="commit_Click"></asp:Button>
</p>
</form>
</section>
</div>
</body>
</html>
Your question is not so simple and you can find a fully tutorial with source code and details on asp.net site:
Creating User Accounts (C#)
Also you can read the article about:Understanding ASP.NET Roles and Membership - A Beginner's Tutorial
If you want to create user by code you can use one of overload method of Create User in Membership class.
MSDN : Membership.CreateUser Method
MembershipCreateStatus status;
var user = Membership.CreateUser(username.Text, password.Text, email.Text, null, null, true, out status);
in my web application I have master page and it has too many content pages and in my content pages I want to post form to other URL. but its not posting the values to other page in this way.
But When I do the same code in simple aspx page without masterpage it works well.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="frmPay">
<div>
<!-- Receiver Details -->
<input type="hidden" name="merchant_id" id="merchant_id" value="xxgxg" >
<input type="hidden" name="merchant_key" id="merchant_key" value="gxgagag" runat="server">
<input type="hidden" name="return_url" id="return_url" value="http://www.widget.co.za/payment_finished" runat="server">
<input type="hidden" name="cancel_url" id="cancel_url" value="http://www.widget.co.za/payment_cancelled" runat="server">
<input type="hidden" name="notify_url" id="notify_url" value="http://www.widget.co.za/payment_notify" runat="server">
<!-- Payer Details -->
<input type="hidden" name="name_first" id="name_first" value="Bob" runat="server">
<input type="hidden" name="name_last" id="name_last" value="Smith" runat="server">
<input type="hidden" name="email_address" id="email_address" value="bob.smith#example.com" runat="server">
<!-- Transaction Details -->
<input type="hidden" name="m_payment_id" id="m_payment_id" value="TRN123456789" runat="server">
<input type="hidden" name="amount" id="amount" value="200.00" runat="server">
<input type="hidden" name="item_name" id="item_name" value="Widget Model 123" runat="server">
<input type="hidden" name="item_description" id="item_description" value="Widget Model 123" runat="server">
<!-- Transaction Options -->
<input type="hidden" name="email_confirmation" id="email_confirmation" value="" runat="server">
<!-- Security -->
<input type="hidden" name="signature" id="signature" value="" runat="server">
<asp:Button ID="Button1" runat="server" PostBackUrl="https://www.payfast.co.za/eng/process" Text="Button" />
</div>
</form>
</asp:Content>
Your <form> element does not have an action="" attribute - the form won't go anywhere (or rather, it will submit to the current URI (whatever it is)). If you want to submit values to another page in ASP.NET you can read this: http://www.codeproject.com/Articles/14092/Cross-Page-Posting-in-ASP-NET-2-0