I have created a user control which has 2 date controls(start date and end date). Now in my aspx page I am using the same user control twice with id as parent and child. Now i want that the dates in the child user control should be within the dates provided in the parent user control.
Please refer to the below code snippet, i want the dates selected to be within the range of the dates.
ASCX Page:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="EffectiveDate.ascx.cs"
Inherits="UserControlDemo.EffectiveDate" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<asp:ScriptManager runat="server" ID="scriptmanger1" EnablePageMethods="true">
</asp:ScriptManager>
<table id="Table5" width="99%" cellspacing="5">
<tr>
<td valign="middle" width="20%">
<asp:Label ID="Label4" runat="server" Style="white-space: nowrap;" Text="Effective Start Date"></asp:Label>
</td>
<td valign="middle">
<asp:TextBox ID="attPrdStartdate" runat="server"></asp:TextBox>
<asp:Label ID="Label8" runat="server" ForeColor="Red" Text="*"></asp:Label>
<asp:ImageButton ID="Image3" runat="server" ImageUrl="/Images/CalendarImage.png"
Style="margin-bottom: -5px" />
<ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender5" runat="server"
TargetControlID="attPrdStartdate" ValidChars="1234567890/" />
<ajaxtoolkit:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="attPrdStartdate"
PopupButtonID="Image3" Format="MM/dd/yyyy">
</ajaxtoolkit:CalendarExtender>
<asp:CompareValidator ID="CompareValidator5" runat="server" ControlToValidate="attPrdStartdate"
Display="Dynamic" ErrorMessage="Invalid Date" ForeColor="Red" Operator="DataTypeCheck"
Type="Date" Style="font-size: smaller">
</asp:CompareValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="attPrdStartdate" Type="Date"
Display="Dynamic" ErrorMessage="Dates out of range" ForeColor="Red" EnableClientScript="False"></asp:RangeValidator>
</td>
</tr>
<tr>
<td valign="middle">
<asp:Label ID="Label5" runat="server" Style="white-space: nowrap;" Text="Effective End Date"></asp:Label>
</td>
<td valign="middle">
<asp:TextBox ID="attPrdEnddate" runat="server"></asp:TextBox>
<asp:Label ID="Label9" runat="server" ForeColor="Red" Text="*"></asp:Label>
<ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server"
TargetControlID="attPrdEnddate" ValidChars="1234567890/" />
<ajaxtoolkit:CalendarExtender ID="CalendarExtender4" runat="server" TargetControlID="attPrdEnddate"
PopupButtonID="Image4" Format="MM/dd/yyyy">
</ajaxtoolkit:CalendarExtender>
<asp:ImageButton ID="Image4" runat="server" ImageUrl="/Images/CalendarImage.png"
Style="margin-bottom: -5px" />
<asp:CompareValidator ID="CompareValidator6" runat="server" ControlToValidate="attPrdEnddate"
Display="Dynamic" ErrorMessage="Invalid Date" ForeColor="Red" ControlToCompare="attPrdStartdate"
Operator="GreaterThan" Type="Date" Style="font-size: smaller">
</asp:CompareValidator>
<asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="attPrdEnddate" Type="Date"
Display="Dynamic" ErrorMessage="Dates out of range" ForeColor="Red" EnableClientScript="False"></asp:RangeValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label runat="server" ID="errlblBaseln" Text="" ForeColor="Red" Font-Size="smaller"></asp:Label>
</td>
</tr>
</table>
ASCX Code Behind:
namespace UserControlDemo
{
public partial class EffectiveDate : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
RangeValidator1.MaximumValue = endDate.ToShortDateString();
RangeValidator1.MinimumValue = startDate.ToShortDateString();
RangeValidator2.MaximumValue = endDate.ToShortDateString();
RangeValidator2.MinimumValue = startDate.ToShortDateString();
}
private DateTime startDate;
private DateTime endDate;
public DateTime StartDate
{
get { return startDate; }
set { startDate = value; }
}
public DateTime EndDate
{
get { return endDate; }
set { endDate = value; }
}
}
}
my aspx page:
<uc:EfectiveDate ID="MyDates" runat="server" StartDate="01/01/2013" EndDate="12/12/2013" />
I think you are trying to do something like this.
Parent
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Parent.ascx.cs" Inherits="StackOverFlow.Parent" %>
<table>
<tr>
<td>Parent Start Date </td>
<td>
<asp:TextBox runat="server" ID="txtStartDate" />
</td>
</tr>
<tr>
<td>Parent End Date </td>
<td>
<asp:TextBox runat="server" ID="txtEndDate" />
</td>
</tr>
</table>
Child
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Child.ascx.cs" Inherits="StackOverFlow.Child" %>
<table>
<tr>
<td>Child Start Date </td>
<td>
<asp:TextBox runat="server" ID="txtStartDate" />
</td>
</tr>
<tr>
<td>Child End Date </td>
<td>
<asp:TextBox runat="server" ID="txtEndDate" />
</td>
</tr>
</table>
Your Page
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="StackOverFlow.WebForm1" %>
<%# Register TagPrefix="p" Src="~/Parent.ascx" TagName="Parent" %>
<%# Register TagPrefix="c" Src="~/Child.ascx" TagName="Child" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<p:Parent ID="parent" runat="server"></p:Parent>
</td>
</tr>
<tr>
<td>
<c:Child ID="child" runat="server"></c:Child>
</td>
</tr>
<tr><td>
<asp:Button Text="Compare" ID="btnCompare" runat="server" OnClick="btnCompare_Click" /></td></tr>
</table>
</div>
</form>
</body>
</html>
Code behind
protected void btnCompare_Click(object sender, EventArgs e)
{
TextBox txtParentStartDate = (TextBox)parent.FindControl("txtStartDate");
if (txtParentStartDate!=null)
{
DateTime dtParentStartDate = Convert.ToDateTime(txtParentStartDate.Text.Trim());
}
//likewise get other dates and compare
}
Hope this will help you.
Related
After fill all the fields , submit button doesn't work and cancel also do nothing.
This function in my _.aspx.cs code:
protected void cancel_Click1(object sender, EventArgs e)
{
Response.Redirect("Home.aspx");}
and this is my aspx code
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="DonorSignUp.aspx.cs"> Inherits="BloodBank.DonorSignUp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
Donor Sign Up Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="contentBody" runat="server">
<
<h1> DONOR REGISTRATION<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnStr %>" SelectCommand="SELECT * FROM [donor_table]"></asp:SqlDataSource>
</h1>
<table>
<tr>
<td> First Name </td>
<td> <asp:TextBox ID="name" runat="server" Width="139px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="name" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Last Name</td>
<td> <asp:TextBox ID="last" runat="server" Width="140px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="last" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<td>Username</td>
<td><asp:TextBox ID="username" runat="server" Width="176px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="username" ErrorMessage="Please enter the usename"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Password</td>
<td><asp:TextBox ID="password" runat="server" Width="170px" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="password" ErrorMessage="password"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Confirm</td>
<td> <asp:TextBox ID="confirm" runat="server" Width="155px" TextMode="Password"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="password" ControlToValidate="confirm" ErrorMessage="password doesn't match"></asp:CompareValidator>
</td>
</tr>
<tr>
<td colspan="2"><asp:Label ID="msgDSignUp" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label2" runat="server" Text="Fill all the blanks"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="SignUpDonor" runat="server" Text="Submit" BackColor="#ff99cc" BorderColor="#ff99cc" OnClick="SignUpDonor_Click1" />
</td>
<td>
<asp:Button ID="cancel" runat="server" Text="Cancel" OnClick="cancel_Click1"/>
</td>
</tr>
</table>
</asp:Content>
When I press cancel button , it does nothing unless I fill all the field in the page ,, if I filled them and press cancel it does the code inside cancel_Click
Can you help me to manipulate this?
This is correct behavior. If you want to test it by going straight to the Cancel event handler, then just comment out all the validators or disable client-side validation temporarily using CausesValidation="false". Validation can occur on both client and server - always best to use both.
Check out this question.
Alright, I have a login page (occurs in register page too) and when I press enter after typing my password to login, it redirects me to the default page but won't do anything else - But when I click the login button, it would login successfully. Why it is happening? Is there a way around it, fixing it?
For example, this is my login.aspx page:
<%# Page Title="התחברות" Language="C#" MasterPageFile="~/MasterPageTest.master" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<center><b>
<asp:Login ID="Login1" runat="server"
LoginButtonText="התחבר" PasswordLabelText="סיסמא:" TitleText="<u><font size=4>התחברות</font></u>"
UserNameLabelText="שם משתמש:" RememberMeText="זכור אותי"
TextLayout="TextOnTop">
<LayoutTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;" dir="rtl">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center">
<u><font size="4">התחברות</font></u></td>
</tr>
<tr>
<td>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">שם משתמש:</asp:Label>
</td>
</tr>
<tr>
<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="Login1"><font color="red">*</font></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">סיסמא:</asp:Label>
</td>
</tr>
<tr>
<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="Login1"><font color="red">*</font></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="RememberMe" runat="server" Text="זכור אותי" />
</td>
</tr>
<tr>
<td align="center" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="התחבר"
ValidationGroup="Login1" />
<br />
<asp:LinkButton ID="ForgotPassLnk" runat="server" Text="שכחתי סיסמא" OnClick="ForgotPassLnk_Click"></asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</b></center>
</asp:Content>
One solution will be:
<asp:TextBox ID="Password" runat="server" TextMode="Password" onkeypress="return EnterEvent(event)"></asp:TextBox>
js
function EnterEvent(e) {
if (e.keyCode == 13) {
//login code
}
}
In Nridubai website,i am using listview EditTemplate for editing purpose. In my EditTemplate, there are controls like..
<asp:TextBox ID="txtEditEventName" runat="server"
Text='<%# Bind("event_name") %>' />
And a few more controls like dropdownlist, calender controls. Now I want to validate using javascript on these controls, but its not working.
Eg.
var eventStatus=document.getElementById("<%=txtEditEventName.ClientID%>").value;
I am not using validation controls. Please help me how to use javascript for validation on EditTemplate Controls? My EditTemplate structure is like the following:
<EditItemTemplate>
<td class="command"><asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
<asp:LinkButton ID="LinkButton2" runat="server" Text="Update" CommandName="Update" />
</td>
<div class="header">View Details for '<%# Eval("event_name")%>'</div>
<tr>
<td class="edit" colspan="6" >
<div class="details">
<table class="detailview" cellpadding="0" cellspacing="0">
<tr>
<td>Event Name:</td>
<td>
<asp:TextBox ID="txtEditEventName" runat="server"
Text='<%# Bind("event_name") %>' />
</td>
<td>VenueAddress :</td>
<td>
<asp:TextBox ID="txtEditVenue" runat="server" Text='<%# Bind("venue") %>' />
</td>
</tr>
<tr>
<td>Country :</td>
<td>
<asp:DropDownList ID="lstEditCountry" runat="server"
Width="174" />
</td>
<td>Event Status:</td>
<td>
<asp:DropDownList ID="lstEditStatus" runat="server" Width="175px" >
<asp:ListItem value='0' Selected="True">-Select-</asp:ListItem>
<asp:ListItem >In-Progress</asp:ListItem>
<asp:ListItem >Completed</asp:ListItem>
<asp:ListItem >Aborted</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Category :</td>
<td>
<asp:DropDownList ID="lstEditCategory" runat="server"
Width="174" />
</td>
</tr>
<tr>
<td>Start Date:</td>
<td>
<asp:TextBox ID="txtEditStartDate" runat="server"
Text='<%# Bind("start_date", "{0:dd/MM/yyyy}") %>' />
</td>
<td>End Date:</td>
<td>
<asp:TextBox ID="txtEditEndDate" runat="server"
Text='<%# Bind("end_date","{0:dd/MM/yyyy}") %>' />
</td>
</tr>
</table>
<div class="footer command">
<asp:LinkButton ID="LinkButton1" runat="server" Text="Close" CommandName="Cancel" />
</div>
</div>
</td>
</tr>
</EditItemTemplate>
You can access the elements on ItemDataBound and emit their ClientIDs for your JavaScript to use:
ItemDataBound:
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
StringBuilder vars= new StringBuilder();
if (ListView1.EditItem != null)
{
TextBox txtEditStartDate = ListView1.EditItem.FindControl("txtEditStartDate") as TextBox;
TextBox txtEditEndDate = ListView1.EditItem.FindControl("txtEditEndDate") as TextBox;
//example js, however I recommend passing the ClientIDs to functions
vars.Append(String.Format("var txtEditStartDate='{0}';" txtEditStartDate.ClientID);
vars.Append(String.Format("var txtEditStartDate='{0}';", txtEditEndDate.ClientID );
ClientScriptManager.RegisterStartUpScript(this.GetType(), "validationVars", vars.ToString(), true);
}
}
***Old Answer, the .NET way************
EditTemplate:
<asp:TextBox ID="txtEditEventName" runat="server"
Text='<%# Bind("event_name") %>' />
<asp:RequiredFieldValidator
id="rfvEditEventName"
ClientValidationFunction="txtEditEventNameClientValidate"
ControlToValidate="txtTitle"
runat="server"
Display="dynamic">*
</asp:RequiredFieldValidator>
JS:
function txtEditEventNameClientValidate(sender, args) {
if (args.Value == '') {
args.IsValid = false; // field is empty
//so something
}
else {
//do something
}
}
Put the validation javascript in the EditTemplate itself. This way, when it switches to edit-mode, the control will be in the context.
I have a web page that contain login control, I face a problem :
The code behind not matched to the design.For example , it gives me an error
Login1 cannot be found in the current context
And when I try to add event to the login it is written as the following:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void LoginButton_Click(object sender, EventArgs e)
{
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
height: 28px;
}
</style>
</head>
<body >
<form id="form1" runat="server">
Name retrieved from ViewState: <asp:Label runat="server" id="NameLabel" />
<div>
</div>
<asp:Login ID="Login1" runat="server" onauthenticate="Login1_Authenticate">
<LayoutTemplate>
<table border="0" cellpadding="1" cellspacing="0"
style="border-collapse:collapse;">
<tr>
<td>
<table border="0" 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="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="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" class="style1">
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Log In" ValidationGroup="Login1" onclick="LoginButton_Click" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</form>
</body>
</html>
Any idea to solve this problem , the big problem is that the code doesn't see the design and vise verse
Firstly :
Make sure that your name space is :
WebApplication4
and the class name is:
_Default
in your code behind file.like this:
namespace WebApplication4
{
public partial class _Default : System.Web.UI.Page
{
}
}
secondly:
Make sure the consistency of the .aspx.designer.cs file.
I mean make sure that there is a reference of your control in this file .like this:
protected global::System.Web.UI.WebControls.Login Login1;
and tell us which Visual studio version does u use.
It sounds like the designer.cs file is out of sync. If you go into the designer.cs file, you can declare the control, like this:
/// <summary>
/// Login1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Login Login1;
You might also try cutting and pasting the markup, so the designer registers all of the controls.
I cannnot get the ModalPopupExtender to work via code. If I set the ModalPopupExtender's property TargetControlID="btn", it works. When I set TargetControlID="HiddenField1" to use the mpe.show() method in the code, it does not work (the dgvResults_RowCommand event fires fine, I have tested it). I have gone through many sites looking at code, and cannot figure out whats wrong. Thanks in advance for any help
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="Michlala._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<style type="text/css">
.modalPopup
{
background-color: Black;
filter: alpha(opacity=80);
opacity: 0.8;
z-index: 10000;
}
.style1
{
width: 100%;
}
.style5
{
text-align: center;
}
</style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h1> Student Feedback</h1>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<asp:TextBox ID="txtSID" runat="server" Width="61px" Height="25px"></asp:TextBox>
<asp:Button ID="btnSID" runat="server" onclick="Button1_Click"
Text="Submit Student ID" />
<asp:GridView ID="dgvResults" runat="server" Visible="False"
onrowcommand="dgvResults_RowCommand">
<Columns>
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="btnFeedback" runat="server" onclick="Button1_Click1"
Text="Add FeedBack" CommandName="InsertFeedback" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="HiddenField1"
PopupControlID="pnlModalPanel"
CancelControlID="btnCancel"
BackgroundCssClass="modalPopup" >
</asp:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Panel ID="pnlModalPanel" runat="server" style="display:none" Width="481px" >
<table class="style1">
<tr>
<td>
Course
</td>
<td>
Semester
</td>
<td class="style5">
Teacher Assitant
</td>
<td class="style5">
Lecturer
</td>
</tr>
<tr>
<td>
 
<asp:TextBox ID="txtCourse" runat="server"></asp:TextBox>
</td>
<td>
 
</td>
<td>
 
</td>
<td>
 
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</td>
<td colspan="2">
 
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
<asp:DropDownList ID="ddlSemester" runat="server">
</asp:DropDownList>
<asp:Label ID="lblRes" runat="server" Text="Label"></asp:Label>
<br />
</asp:Content>
in the server side code
protected void dgvResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
ModalPopupExtender mpe = new ModalPopupExtender();
mpe.Show();
}
You need to fin the ModalPopupExtender in the selected row and then call it with the name:
if (e.CommandName.Equals("InsertFeedback"))
{
int index = Convert.ToInt32(e.CommandArgument);
// Retrieve the row that contains the button clicked
// by the user from the Rows collection.
GridViewRow row = dgvResults.Rows[index];
ModalPopupExtender mpe = (ModalPopupExtender)row.FindControl("ModalPopupExtender1");
mpe.Show();
}