I have one Panel that is linked to a ModelPopupExtenderand there is a button inside the first panel. When I click the first panel's button I want it to execute the event and inside this event I want to pop up the second Panel which is also linked to a ModelPopupExtender, but when I click the first Panel's button the event does not trigger.
Asp Code :
<input type="hidden" runat="server" id="hdnEditBank1" />
<asp:Panel runat="server" ID="pnl1" CssClass="Modal450h450w" Height="300px">
<table id="tblEditBank1" runat="server">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td align="right" colspan="2"><img runat="server" id="imgExitEdit1" src="../images/Exit_cross.png" /></td>
</tr>
<tr>
<td colspan="3">Name : </td>
<td colspan="2"><telerik:RadTextBox ID="txt1" runat="server" CssClass="largebox"></telerik:RadTextBox></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan="4">
<asp:Button runat="server" ID="btnClose" Text="Close" OnClick="btnAdd_Close_Click" />
</td>
<td align="right">
<asp:Button runat="server" ID="btnNext" Text="Next" OnClick="btnEdit_Next_Click" />
</td>
</tr>
</table>
</asp:Panel>
<!-- second panel -->
<asp:ModalPopupExtender ID="ModalPopupExtender6" runat="server" TargetControlID="btnNext" OkControlID="imgExitEdit1"
PopupControlID="pnl2" BackgroundCssClass="LoadingBackground" >
</asp:ModalPopupExtender>
<input type="hidden" runat="server" id="Hidden1" />
<asp:Panel runat="server" ID="pnl2" CssClass="Modal450h450w" Height="300px">
<table id="Table1" runat="server">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td align="right" colspan="2"><img runat="server" id="img1" src="../images/Exit_cross.png" /></td>
</tr>
<tr>
<td colspan="3">Some Label : </td>
<td colspan="3"><telerik:RadTextBox ID="txtSomeText" runat="server" CssClass="largebox"></telerik:RadTextBox></td>
</tr>
<tr>
<td colspan="4">
<asp:Button runat="server" ID="btnIbanClose" Text="Close" OnClick="btnAdd_Close_Click" />
</td>
<td align="right">
<asp:Button runat="server" ID="btnIbanReview" Text="Next" OnClick="btnEdit_Next_Click" />
</td>
</tr>
</table>
</asp:Panel>
The code behind :
protected void btnEdit_Next_Click(object sender, EventArgs e)
{
ModalPopupExtender6.Show();
}
I am thinking it's about the AutoPostBack but I am not sure how to resolve this
I have found the solution to this if anybody is interested.
What you need to do is create a hidden input field and set the TargetControlID to the hidden control and from there you are able to fire off the buttons event.
<input type="hidden" runat="server" id="hdnNext" />
<asp:ModalPopupExtender ID="ModalPopupExtender6" runat="server" TargetControlID="hdnNext" OkControlID="imgExitEdit1"
PopupControlID="pnlIban" BackgroundCssClass="LoadingBackground" >
</asp:ModalPopupExtender>
The input field is used in this case as a Dummy control where the ModalPopupExtender points to and from the buttons event you are able to control which other ModalPopupExtenders you want to control.
Related
I have a multiview control, that has two views. View1 is the default view, and View2 is the new view. When the end user click a button, I want to change the view to View2. I can't seem to achieve this anyway I go.
ASP.NET Code:
<asp:MultiView ID="MVOrder" runat="server">
<asp:View ID="VOrderNow" runat="server">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label ID="LblInfo" runat="server"></asp:Label>
</td>
<td>
</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="LblDrink" runat="server"></asp:Label>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>
<asp:Label ID="LblItemInfo" runat="server"></asp:Label>
</td>
<td>
</td>
<td> </td>
</tr>
</table>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:View>
<asp:View runat="server" ID="VOrderComplete">
<table class="auto-style1">
<tr>
<td> </td>
<td>
<asp:Label ID="LblOrderComplete" runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<asp:Label ID="LblOrderNumberAgain" runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<asp:Label ID="LblOrderTimeAgain" runat="server"></asp:Label>
</td>
<td> </td>
</tr>
</table>
</asp:View>
<br/>
</asp:MultiView>
Button Click Event Code:
protected void Button1_Click(object sender, EventArgs e)
{
//MVOrder.ActiveViewIndex = 1;
MVOrder.SetActiveView(VOrderComplete);
}
Page Load Code:
if (!IsPostBack)
{
MVOrder.SetActiveView(VOrderNow);
}
Can someone please tell me what I am doing wrong?
I think you might have some additional code that might make this not work properly. But based on what you've shown, this will post and update your view:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:MultiView ID="MVOrder" runat="server">
<asp:View ID="VOrderNow" runat="server">
<table>
<tr>
<td><asp:Label ID="LblInfo" runat="server" Text="asdfasdfasdf"></asp:Label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><asp:Label ID="LblDrink" runat="server" Text="lmnoplmnop"></asp:Label></td>
<td></td>
<td></td>
</tr>
<tr>
<td><asp:Label ID="LblItemInfo" runat="server" Text="iteminfo"></asp:Label></td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</asp:View>
<asp:View runat="server" ID="VOrderComplete">
<table class="auto-style1">
<tr>
<td> </td>
<td><asp:Label ID="LblOrderComplete" runat="server" Text="ordercomplete"></asp:Label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><asp:Label ID="LblOrderNumberAgain" runat="server" Text="ordernumberagain"></asp:Label></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><asp:Label ID="LblOrderTimeAgain" runat="server" Text="ordertimeagain"></asp:Label></td>
<td> </td>
</tr>
</table>
</asp:View>
<br />
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
I have a simple form as you see, the DOB date of birth, field, I would like to have it
with a date picker, how is the best way for this?
tr>
<td>
<dx:ASPxLabel ID="ASPxLabel8" runat="server" Text="DOB:" Width="50px"></dx:ASPxLabel>
</td>
<td align="left">
</td>
<td>
<dx:ASPxTextBox ID="tbDOB" runat="server" Width="100px"></dx:ASPxTextBox>
</td>
<td align="right">
<dx:ASPxLabel ID="ASPxLabel9" runat="server" Text="Weight:" Width="50px"></dx:ASPxLabel>
</td>
<td align="left">
<dx:ASPxTextBox ID="tbWeight" runat="server" Width="100px"></dx:ASPxTextBox>
</td>
<td align="right">
<dx:ASPxLabel ID="ASPxLabel10" runat="server" Text="Height:" Width="50px"></dx:ASPxLabel>
</td>
<td align="left">
<dx:ASPxTextBox ID="tbHeight" runat="server" Width="100px"></dx:ASPxTextBox>
</td>
<td align="right">
<dx:ASPxLabel ID="ASPxLabel11" runat="server" Text="BP:" Width="50px"></dx:ASPxLabel>
</td>
<td align="left">
<dx:ASPxTextBox ID="tbBP" runat="server" Width="100px"></dx:ASPxTextBox>
</td>
<td align="right">
<dx:ASPxLabel ID="ASPxLabel12" runat="server" Text="Pulse:" Width="50px"></dx:ASPxLabel>
</td>
<td align="left">
<dx:ASPxTextBox ID="tbPulse" runat="server" Width="100px" ></dx:ASPxTextBox>
</td>
</tr>
very simple way to do this would be to use Jquery's built in datepicker like this:
<dx:ASPxTextBox ID="tbDOB" runat="server" Width="100px"></dx:ASPxTextBox>
and In the script tag:
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("#tbDOB").datepicker();
});
</script>
DEMO: http://jsfiddle.net/WzLc3/3/
ALSO:
If you cannot use Jquery for your application, you can do this purely through asp.net but lightly more complicated by using the calander contorl.
here is a great tutorial for beginners to walk you through the steps,
http://www.dotnetfunda.com/articles/article746-how-to-create-a-date-picker-in-aspnet.aspx
I've got 5 required field validators on an aspx page.
With all validators active, none of the code behind any of the command buttons on the page will fire.
However, with ANY four out of five validators active, buttons all function ok.
Is there a limit to the amount of validators that can be used on a single page? Is there any other reason that this could be happening?
Help appreciated, thanks..
Daf.
Markup looks like this..
> <%# Page Title="" Language="C#" MasterPageFile="~/MasterPages/Admin.Master" AutoEventWireup="true" CodeBehind="RegisterUser.aspx.cs" Inherits="LectureQuestions.Interface.Admin.RegisterUser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" runat="server">Register New User
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="TitleTxt" runat="server">Register New User
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<table ID="tblInputField" runat="server" width="100%" cellspacing="15">
<tr>
<td width="10%"></td>
<td width="20%">First Name</td>
<td width="60%">
<asp:TextBox ID="txtFirstName" runat="server" Width="98%"></asp:TextBox>
</td>
<td width="10%">
<asp:RequiredFieldValidator ID="txtFirstNameRequired" runat="server"
ControlToValidate="txtFirstName" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td width="10%"></td>
<td width="20%">Last Name</td>
<td width="60%">
<asp:TextBox ID="txtLastName" runat="server" Width="98%"></asp:TextBox>
</td>
<td width="10%">
<asp:RequiredFieldValidator ID="txtLastNameRequired" runat="server"
ControlToValidate="txtLastName" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td width="10%"></td>
<td width="20%">E-mail</td>
<td width="60%">
<asp:TextBox ID="txtEmail" runat="server" Width="98%"></asp:TextBox>
</td>
<td width="10%">
<asp:RequiredFieldValidator ID="txtEmailRequired" runat="server"
ControlToValidate="txtEmail" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td width="10%"></td>
<td width="20%">Phone</td>
<td width="60%">
<asp:TextBox ID="txtPhone" runat="server" Width="98%"></asp:TextBox>
</td>
<td width="10%">
<asp:RequiredFieldValidator ID="txtPhoneRequired" runat="server"
ControlToValidate="txtPhone" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td width="10%"></td>
<td width="20%">Password</td>
<td width="60%">
<asp:TextBox ID="txtPassword" runat="server" Width="98%"></asp:TextBox>
</td>
<td width="10%">
<asp:RequiredFieldValidator ID="txtPasswordRequired" runat="server"
ControlToValidate="txtPassword" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td width="10%"></td>
<td width="20%">User Type</td>
<td width="60%">
<asp:DropDownList ID="txtUserType" runat="server" Width="99.5%">
<asp:ListItem>-- Please Select --</asp:ListItem>
<asp:ListItem>Student</asp:ListItem>
<asp:ListItem>Lecturer</asp:ListItem>
<asp:ListItem>Admin</asp:ListItem>
</asp:DropDownList>
</td>
<td width="10%">
<asp:Label id="txtUserTypeValidation" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td width="10%"></td>
<td width="20%">Course</td>
<td width="60%">
<asp:DropDownList ID="txtCourse" runat="server" Width="99.5%">
</asp:DropDownList>
</td>
<td width="10%"></td>
</tr>
</table>
<table ID="tblAllValidationMsg" runat="server" width="100%" cellspacing="5">
<tr>
<td width="10%"></td>
<td width="80%" align="center">
<asp:Label id="allValidationMsg" runat="server" height="22px" ForeColor="Red"></asp:Label>
</td>
<td width="10%"></td>
</tr>
</table>
<table ID="tblCommandButtons" runat="server" width="100%" cellspacing="10">
<tr>
<td width="25%"></td>
<td width="25%" align="right">
<asp:Button class="navbutton" ID="btnRegister" runat="server"
Text="Register User" OnClick="btnRegister_Click" />
</td>
<td width="25%" align="left">
<asp:Button class="navbutton" ID="btnCancel" runat="server"
Text="Cancel" onclick="btnCancel_Click" />
</td>
<td width="25x%"></td>
</tr>
</table>
</asp:Content>
Answer:
No there is no limit to validations on the page.
Misc:
Pranay has provided the fix in his answer.
In the end, I placed a second regular expression validator on one of the fields for testing.
When I removed this validator, problem ceased. Don't know how or why; any advice on this welcome..
Here is my code
<asp:Repeater ID="rpRatesheetDetails" runat="server"
onitemcommand="rpRatesheetDetails_ItemCommand"
onitemdatabound="rpRatesheetDetails_ItemDataBound">
<HeaderTemplate>
<tr>
<td width="110" height="25px" class="content">
<table cellpadding="0" cellspacing="1">
<tr>
<td style="cursor:pointer;" runat="server" onclick="toggle();">
Carrier
</td>
<td align="right">
<asp:ImageButton ID="btnCarrierSortAsc" runat="server" ImageUrl="~/Images/Arrow_T.png" ToolTip="Sort Ascending Order" style="display:none;"
CommandName="SortCarrierASC" />
</td>
<td align="right">
<asp:ImageButton ID="btnCarrierSortDsc" runat="server" ImageUrl="~/Images/Arrow_B.png" ToolTip="Sort Descending Order" style="display:none;"
CommandName="SortCarrierDESC" />
</td>
</tr>
</table>
</td>
<td width="110" class="content">
<table cellpadding="0" cellspacing="1">
<tr>
<td>
Date
</td>
<td align="right">
<asp:ImageButton ID="btnDateSortAsc" runat="server" ImageUrl="~/Images/Arrow_T.png" ToolTip="Sort Ascending Order" style="display:none;"
CommandName="SortDateASC" />
</td>
<td align="right">
<asp:ImageButton ID="btnDateSortDesc" runat="server" ImageUrl="~/Images/Arrow_B.png" ToolTip="Sort Descending Order" style="display:none;"
CommandName="SortDateDESC" />
</td>
</tr>
</table>
</td>
<td width="82" class="content">
Call Type
</td>
<td width="110" class="content">
Format
</td>
<td width="100" class="content">
<table cellpadding="0" cellspacing="1">
<tr>
<td>
Status
</td>
<td align="right">
<asp:ImageButton ID="btnStatusAsc" runat="server" ImageUrl="~/Images/Arrow_T.png" ToolTip="Sort Ascending Order" style="display:none;"
CommandName="SortStatusASC" />
</td>
<td align="right">
<asp:ImageButton ID="btnStatusDsc" runat="server" ImageUrl="~/Images/Arrow_B.png" ToolTip="Sort Descending Order" style="display:none;"
CommandName="SortStatusDESC" />
</td>
</tr>
</table>
</td>
<td width="70" class="content">
User
</td>
<td width="82" class="content">
File Name
</td>
<td width="110" class="content">
System
</td>
<td width="110" class="content">
<table cellpadding="0" cellspacing="1">
<tr>
<td>
No. Of Days
</td>
<td align="right">
<asp:ImageButton ID="btnDaysAsc" runat="server" ImageUrl="~/Images/Arrow_T.png" ToolTip="Sort Ascending Order"
CommandName="SortNoOfDaysASC" />
<asp:ImageButton ID="btnDaysDsc" runat="server" ImageUrl="~/Images/Arrow_B.png" ToolTip="Sort Descending Order"
CommandName="SortNoOfDaysDESC" />
</td>
</tr>
</table>
</td>
</tr>
</HeaderTemplate>
Above is the header template of my repeater.By default when my repeater loads it is sorted by the last column.Now i want dat if the user want to sort by any other column he should click on dat column.Only den the sort icon will be shown and the records will be sorted.I am showing this icon on the ItemDataBound event but how to fire an ItemDataBound event while clicking on header??
The order of the items in the repeater depends on the order in the bound collection (the DataSource).
Sort the items in the DataSource before binding in order to get a sorted list in your repeater.
Do this in your rpRatesheetDetails_ItemCommand - check the command name, sort the collection accordingly, then bind.
I have an image button for login in my system. so as the most common thing i m having two text boxes txt_username and txt_password.
i have put required field validator for both the text boxes. and set the validation group "a" and respective control to validate for both of them. the source code for my ImageButton is as follows:-
<td align="right" class="simple_text"> </td>
<td align="left">
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="true"
ImageUrl="~/images/signin_button.gif" onclick="ImageButton1_Click"
ValidationGroup="a" />
</td>
now I am fed up as when I run my application and click the ImageButton it doesn't respond to the validation at all and redirects to the next page. Can anyone say why is it so? this is the first time wherein the validators are not working.
this is source code:-
<td align="left"><table width="480" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="178" align="right" class="simple_text">User Name : </td>
<td width="302" align="left">
<asp:TextBox ID="txt_username" runat="server"
CssClass="text_box_username" Width="180px" AutoPostBack="True"
ontextchanged="txt_username_TextChanged" ValidationGroup="a"
CausesValidation="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_username" ErrorMessage="RequiredFieldValidator"
ValidationGroup="a">**</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="simple_text"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="right" class="simple_text">Password : </td>
<td align="left">
<asp:TextBox ID="txt_password" runat="server" CssClass="text_box_password"
TextMode="Password" Width="180px" ValidationGroup="a"
CausesValidation="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txt_password" ErrorMessage="RequiredFieldValidator"
ValidationGroup="a">**</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="simple_text"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="right" class="simple_text"> </td>
<td align="left">
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="true"
ImageUrl="~/images/signin_button.gif" onclick="ImageButton1_Click"
ValidationGroup="a" />
</td>
</tr>
</table></td>
</tr>
<tr>
<td align="left"> </td>
</tr>
<tr>
hi just paste this code will work surely for you
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<td align="left"><table width="480" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="178" align="right" class="simple_text">User Name : </td>
<td width="302" align="left">
<asp:TextBox ID="txt_username" runat="server"
Width="180px" AutoPostBack="True"
ValidationGroup="a"
CausesValidation="True" ontextchanged="txt_username_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_username" ErrorMessage="RequiredFieldValidator"
ValidationGroup="a">**</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="simple_text"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="right" class="simple_text">Password : </td>
<td align="left">
<asp:TextBox ID="txt_password" runat="server"
TextMode="Password" Width="180px" ValidationGroup="a"
CausesValidation="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txt_password" ErrorMessage="RequiredFieldValidator"
ValidationGroup="a">**</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="simple_text"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="right" class="simple_text"> </td>
<td align="left">
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="true"
ImageUrl="~/images/signin_button.gif" onclick="ImageButton1_Click"
ValidationGroup="a" />
</td>
</tr>
</table></td>
</tr>
<tr>
<td align="left"> </td>
</tr>
<tr>
</div>
</form>
</body>
</html>
Hope you provided the validationGroup property properly.
Specifying Validation Groups
How about this:
<asp:ImageButton runat="server" CausesValidation="true" ImageUrl="..." />
CausesValidation="true" might force the validation to run.