Can't get multiview control to change views - c#

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>

Related

Tabcontainer issue with rendering the tab stripe

enter code![as you can see here the tabs are half eaten!][1] here
Hello, I have a problem with showing the tab stripe I don't know what is wrong with it. can any one help? when I run this the tabs are not fully shown I have three tabs and I tried this with different browsers but the issue persists.
below is a sample of the code:
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" BackColor="#62A5C8" BorderStyle="none" ForeColor="#ffffff" Height="450px" server="" Style=" background-color:#012F54; margin-top: 0px;" Width="100%" ScrollBars="Both" Font-Size="Medium"
ToolTip="Move between tabs to fill-in all information">
<asp:TabPanel runat="server" HeaderText="Student Information" ID="TabPanel1">
<ContentTemplate>
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<table class="auto-style15">
<tr>
<td class="auto-style27">
<br />
<span class="auto-style117">First Name:<br /> </span>
</td>
<td class="auto-style21">
<br />
<strong>
<asp:TextBox ID="TextBox1" runat="server" BorderColor="Black" BorderStyle="Solid" Height="23px" Width="198px" CssClass="auto-style116"></asp:TextBox>
</strong>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style28"> </td>
<td class="auto-style21"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style117">Last Name:</td>
<td class="auto-style24"><strong>
<asp:TextBox ID="TextBox2" runat="server" BorderStyle="Solid" Height="21px" Width="198px" BorderColor="Black" CssClass="auto-style116"></asp:TextBox>
</strong>
</td>
<td class="auto-style25"></td>
</tr>
<tr>
<td class="auto-style17"></td>
<td class="auto-style20"></td>
<td class="auto-style18"></td>
</tr>
<tr>
<td class="auto-style27" style="font-size: small; color: #043d5d">Student ID:</td>
<td class="auto-style21"><strong>
<asp:TextBox ID="TextBox3" runat="server" BorderStyle="Solid" Height="23px" Width="198px" BorderColor="Black" CssClass="auto-style116"></asp:TextBox>
</strong>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style28"> </td>
<td class="auto-style21"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style27" style="font-size: small; color: #043d5d">Department:</td>
<td class="auto-style21"><strong>
<asp:DropDownList ID="DropDownList1" runat="server" Height="27px" Width="295px" style="margin-left:7px;">
<asp:ListItem>Cardiac Technology</asp:ListItem>
<asp:ListItem>Clinical Laboratory Sciences</asp:ListItem>
</asp:DropDownList>
</strong>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style28"> </td>
<td class="auto-style21"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style28"> </td>
<td class="auto-style21"> </td>
</tr>
<tr>
<td class="auto-style28"> </td>
<td class="auto-style21"> </td>
</tr>
<tr>
<td class="auto-style28"> </td>
<td class="auto-style21"> </td>
<td>
<asp:Button ID="Button1" runat="server" BackColor="#4DA3B0" BorderColor="#4DA3B0" Font-Bold="False" Font-Size="12pt" ForeColor="White" Height="36px" style="margin-left:10px;" Text="Next ►" Width="166px" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server" HeaderText="Graduate Form">
<ContentTemplate>
**
Hi brother use below code
first add refrence at the top of the page
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
then use below code
<asp:ScriptManager runat="server" ID="sc">
</asp:ScriptManager>
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" BackColor="#62A5C8"
BorderStyle="none" ForeColor="#ffffff" Height="450px" server="" Style="background-color: #012F54;
margin-top: 0px;" Width="100%" ScrollBars="Both" Font-Size="Medium" ToolTip="Move between tabs to fill-in all information">
<asp:TabPanel runat="server" HeaderText="Student Information" ID="TabPanel1">
<ContentTemplate>
<table class="auto-style15">
<tr>
<td class="auto-style27">
<br />
<span class="auto-style117">First Name:<br />
</span>
</td>
<td class="auto-style21">
<br />
<strong>
<asp:TextBox ID="TextBox1" runat="server" BorderColor="Black" BorderStyle="Solid"
Height="23px" Width="198px" CssClass="auto-style116"></asp:TextBox>
</strong>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style28">
</td>
<td class="auto-style21">
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style117">
Last Name:
</td>
<td class="auto-style24">
<strong>
<asp:TextBox ID="TextBox2" runat="server" BorderStyle="Solid" Height="21px" Width="198px"
BorderColor="Black" CssClass="auto-style116"></asp:TextBox>
</strong>
</td>
<td class="auto-style25">
</td>
</tr>
<tr>
<td class="auto-style17">
</td>
<td class="auto-style20">
</td>
<td class="auto-style18">
</td>
</tr>
<tr>
<td class="auto-style27" style="font-size: small; color: #043d5d">
Student ID:
</td>
<td class="auto-style21">
<strong>
<asp:TextBox ID="TextBox3" runat="server" BorderStyle="Solid" Height="23px" Width="198px"
BorderColor="Black" CssClass="auto-style116"></asp:TextBox>
</strong>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style28">
</td>
<td class="auto-style21">
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style27" style="font-size: small; color: #043d5d">
Department:
</td>
<td class="auto-style21">
<strong>
<asp:DropDownList ID="DropDownList1" runat="server" Height="27px" Width="295px" Style="margin-left: 7px;">
<asp:ListItem>Cardiac Technology</asp:ListItem>
<asp:ListItem>Clinical Laboratory Sciences</asp:ListItem>
</asp:DropDownList>
</strong>
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style28">
</td>
<td class="auto-style21">
</td>
<td>
</td>
</tr>
<tr>
<td class="auto-style28">
</td>
<td class="auto-style21">
</td>
</tr>
<tr>
<td class="auto-style28">
</td>
<td class="auto-style21">
</td>
</tr>
<tr>
<td class="auto-style28">
</td>
<td class="auto-style21">
</td>
<td>
<asp:Button ID="Button1" runat="server" BackColor="#4DA3B0" BorderColor="#4DA3B0"
Font-Bold="False" Font-Size="12pt" ForeColor="White" Height="36px" Style="margin-left: 10px;"
Text="Next ►" Width="166px" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server" HeaderText="Graduate Form">
<ContentTemplate>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>

Showing comments without reloading page

The code below get me a comment , puts it in the database and then waits for a page reload to show the comment. How can i make the submited comment to be shown right after it has been posted along with the new ones ? This is the code that does the stuff :
Layout:
<table>
<tr>
<td colspan="2">All Comments</td>
<td>
&nbsp
</td>
</tr>
<tr> <td colspan="2"> </td></tr>
<tr>
<td>
<asp:Repeater ID="Repeater1" runat="server" ItemType="SiteStiri.Models.Comments" SelectMethod="GetComments" >
<ItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label id="lblDate" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblComment" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<AlternatingItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label id="Label1" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="Label2" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</td>
</tr>
<td>
<table>
<tr>
<td colspan="2" >Add Your Comment</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblStatus" runat="server" Visible="False"></asp:Label>
</td>
<td>
&nbsp
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txtcomment" runat="server" TextMode="MultiLine">
</asp:TextBox>
</td>
<td>
&nbsp
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</td>
<td>
&nbsp
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
Code Behind:
public void fnSubmitComment()
{
AddComment cmt = new AddComment();
String x = Request.QueryString["newsID"].ToString();
int y = Convert.ToInt32(x);
bool addSucces = cmt.Addcomment( y , txtcomment.Text);
if (addSucces)
{
lblStatus.Text = "Your Comment has been Added Successfully.";
}
else
{
lblStatus.Text = "Your Comment has not been Added.";
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
fnSubmitComment();
}
public IQueryable<Comments> GetComments()
{
var _db = new SiteStiri.Models.CommentsContext();
IQueryable<Comments> query = _db.Comments;
String x = Request.QueryString["newsID"].ToString();
int y = Convert.ToInt32(x);
query = query.Where(p => p.NewsID == y);
return query;
}
I heard i can do that with ajax ? (My knowledge about ajax is 0 currently) Any tips on how i can do this ?
You must wrapper you repeater in an updatepanel,
set UpdateMode="Conditional" and add a trigger on btnSubmit so when click the button the update the repeater with the normal page life cycle
Remember to bind the repeater after that you add the commet in the codebehind and must be present in your page a ScriptManager control
more or less thus
<asp:ScriptManager runat="server" />
<table>
<tr>
<td colspan="2">All Comments</td>
<td>&nbsp
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td>
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" ItemType="SiteStiri.Models.Comments" SelectMethod="GetComments">
<ItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label ID="lblDate" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblComment" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<AlternatingItemTemplate>
<table>
<tr>
<td colspan="2">
<asp:Label ID="Label1" runat="server" Text='<%# Item.ReleaseDate %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="Label2" runat="server" Text='<%# Item.Comment %>'>
</asp:Label>
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td colspan="2">Add Your Comment</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblStatus" runat="server" Visible="False"></asp:Label>
</td>
<td>&nbsp
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="txtcomment" runat="server" TextMode="MultiLine">
</asp:TextBox>
</td>
<td>&nbsp
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</td>
<td>&nbsp
</td>
</tr>
</table>
</td>
</tr>
</table>

Limit to number of client-side validators on one aspx page?

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..

ASP.NET button event not firing when using modelpopupextender

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.

How to initialize onclick method before ModalPopupExtender take place?

because I manually want to show the modal popup (this might be due to the fact that the controls inside the popup have to initialized according to the pressed button or row). Can anyone help me? The button NEVER goes to this EditBtn_Click method, it just aways show my panel.
Code:
protected void EditBtn_Click(object sender, EventArgs e)
{
LinkButton btn = (LinkButton)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
int i = Convert.ToInt32(row.RowIndex);
string uid = (string)ManageStaffGrid.Rows[i].Cells[1].Text;
//bind panel
AjaxControlToolkit.ModalPopupExtender mpe = (AjaxControlToolkit.ModalPopupExtender)row.FindControl("EditBtn_ModalPopupExtender");
mpe.Show(); //show the modal popup extender
}
Design:
(from grid)
<ItemTemplate>
<asp:LinkButton ID="EditBtn" runat="server" onclick="EditBtn_Click">Edit</asp:LinkButton>
<asp:ModalPopupExtender ID="EditBtn_ModalPopupExtender" runat="server" CancelControlID="CancelBtn" Enabled="True" PopupControlID="UpdatePanel" TargetControlID="EditBtn">
</asp:ModalPopupExtender>
</ItemTemplate>
<asp:Panel ID="UpdatePanel" runat="server" Style="display: none" BackColor="White" GroupingText="Update User">
<div>
<table><tr>
<td style="width:12px"></td>
<td><asp:Label ID="lblLegend" runat="server" Text=""></asp:Label></td></tr></table>
<br />
<table>
<tr>
<td style="width:12px"></td>
<td style="width: 76px">
<asp:Label ID="lblName" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:Label ID="lblStaffName" runat="server"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td style="width:12px"> </td>
<td style="width: 76px">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
<asp:Label ID="lblUserId" runat="server" Text="User ID"></asp:Label>
</td>
<td>
<asp:Label ID="lblStaffUid" runat="server"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td valign="top" style="width: 70px">
<asp:Label ID="lblSection" runat="server" Text="Section"></asp:Label>
</td>
<td>
<asp:ListBox ID="listSection" runat="server" SelectionMode="Multiple"
CssClass="standardManage" onMouseDown="GetCurrentListValues(this);"
onchange="FillListValues(this);">
</asp:ListBox>
</td>
<td valign="top">
<asp:RequiredFieldValidator ID="RequiredValidatorSection" runat="server"
ControlToValidate="listSection" Display="Dynamic" EnableClientScript="False"
EnableTheming="True" ErrorMessage="Required" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:Label ID="lblValidatorSection" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
<asp:Label ID="lblFunction" runat="server" Text="Function"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlFunction" runat="server" CssClass="standardManage">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
<asp:Label ID="lblStaffGender" runat="server" Text="Gender"></asp:Label>
</td>
<td>
<asp:Label ID="lblGender" runat="server"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
<asp:Label ID="lblRole" runat="server" Text="Role"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlRole" runat="server" CssClass="standardManage">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 76px">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td> </td>
<td style="width: 70px">
</td>
<td align="right">
<asp:Button ID="UpdateBtn" runat="server" Text="Update" OnClick="UpdateBtn_Click"/>
<asp:Button ID="CancelBtn" runat="server" Text="Cancel" />
</td>
<td>
</td>
</tr>
</table>
</div></asp:Panel>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
i found a very helpful link that eventually solves my problems! Please check it out!
http://www.aspdotnet-suresh.com/2011/03/how-to-show-modalpopup-to-edit-gridview.html

Categories