Cannot get the ModalPopupExtender to run via code - asp.net

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>
&nbsp
<asp:TextBox ID="txtCourse" runat="server"></asp:TextBox>
</td>
<td>
&nbsp
</td>
<td>
&nbsp
</td>
<td>
&nbsp
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</td>
<td colspan="2">
&nbsp
<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();
}

Related

Update panel Avoid page reload when Radio button is checked not working

I am trying to use 2 Radio buttons and swap the view according to the radio button selected, but it's not working, the page does not reload and nothing happens.
can someone tell me where is the problem?
<%# Page Title="" Language="C#" MasterPageFile="~/Admin Part/Admin.Master" AutoEventWireup="true" CodeBehind="DataEntry.aspx.cs" Inherits="_4Kids.Admin_Part.DataEntry" EnableEventValidation="false" %>
<%# Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="ajaxToolkit" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="upd" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td style="height: 21px;">
<asp:RadioButton ID="rdb_Preterm" runat="server" Text="Preterm" AutoPostBack="true" OnCheckedChanged="rdb_Preterm_CheckedChanged" />
<asp:RadioButton ID="rdb_Fulterm" runat="server" Text="Full term" AutoPostBack="true" OnCheckedChanged="rdb_Fulterm_CheckedChanged" />
</td>
<td style="height: 21px;">
<asp:MultiView ID="Mul" runat="server">
<asp:View ID="view_null" runat="server"></asp:View>
<asp:View ID="view_weeks" runat="server">
<table>
<tr>
<td>
<asp:Label ID="Label14" runat="server" Text="Weeks:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_pretermWeeks" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdb_Preterm" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="rdb_Fulterm" EventName="CheckedChanged"/>
</Triggers>
</asp:UpdatePanel>
</asp:Content>
A few things:
In your posted markup, I don't seen anything related to the ajaxtoolkit.
So, remove that stuff. Also, remove the post back triggers. They are really for causing OTHER update panels to trigger - and you don't have multiple panels, so dump that stuff.
You do however need the script manager due to use of the update panel.
So, we now have this:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="upd" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table>
<tr>
<td style="height: 21px;">
<asp:RadioButton ID="rdb_Preterm" runat="server"
Text="Preterm" AutoPostBack="true" OnCheckedChanged="rdb_Preterm_CheckedChanged" />
<asp:RadioButton ID="rdb_Fulterm" runat="server"
Text="Full term" AutoPostBack="true" OnCheckedChanged="rdb_Fulterm_CheckedChanged" />
</td>
<td style="height: 21px;">
<asp:MultiView ID="Mul" runat="server">
<asp:View ID="view_null" runat="server"></asp:View>
<asp:View ID="view_weeks" runat="server">
<table>
<tr>
<td>
<asp:Label ID="Label14" runat="server" Text="Weeks:"></asp:Label>
</td>
<td>
<asp:TextBox ID="txt_pretermWeeks" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
And you code behind can be this:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void rdb_Preterm_CheckedChanged(object sender, EventArgs e)
{
if (rdb_Preterm.Checked)
{
rdb_Fulterm.Checked = false;
Mul.SetActiveView(view_null);
}
}
protected void rdb_Fulterm_CheckedChanged(object sender, EventArgs e)
{
if (rdb_Fulterm.Checked)
{
rdb_Preterm.Checked = false;
Mul.SetActiveView(view_weeks);
}
}
That's all you really should need here. As noted, no need for the triggers, you ALREADY have postback=true for the radio buttons.

Asp.NET user control date validation

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.

Modal Pop up is not displaying update panel in asp.net

This is my aspx page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TotalFee.aspx.cs" Inherits="TotalFee" %>
<%# Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
// function ok(sender, e) {
// alert("Hello");
// __doPostBack('btnCreateBill','btnCreateBill_Click');
// }
// function cancel(sender, e) {
// $find('ModalPopupExtender1').hide();
// }
//
</script>
<style type="text/css">
.style2
{
font-size: x-large;
font-family: "Times New Roman", Times, serif;
}
.style3
{
color: #FF0000;
}
.panel
{
position:static;
top: 80%;
left:50%;
background-color:Aqua;
}
.modalBackground
{
z-index:auto;
}
</style>
</asp:Content>
<asp:Content ID="Content2" runat="server" contentplaceholderid="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<table style="width:100%">
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="Classlabel" runat="server" Text="Class" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:DropDownList ID="ClassDropDownList" runat="server" Width="150px"
DataSourceID="SqlDataSource1" DataTextField="ClassName"
DataValueField="ClassName" AutoPostBack="True"
onselectedindexchanged="ClassDropDownList_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbbilling2.0ConnectionString4 %>"
SelectCommand="SELECT [ClassName] FROM [tblClass]"></asp:SqlDataSource>
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="StudentNamelabel" runat="server" Text="StudentName" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:DropDownList ID="StudentNameDropDownList" runat="server" Width="150px"
DataSourceID="SqlDataSource2" DataTextField="StudentName"
DataValueField="StudentID" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:dbbilling2.0ConnectionString3 %>"
SelectCommand="SELECT [StudentID], [StudentName] FROM [tblStudentInfo] WHERE ([Class] = #Class)">
<SelectParameters>
<asp:ControlParameter ControlID="ClassDropDownList" Name="Class"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="Monthlabel" runat="server" Text="Month" CssClass="style2"></asp:Label>
<br />
<br />
<br />
<br />
<br />
</td>
<td valign="top" align="center">
<asp:DropDownList ID="MonthDropDownList" runat="server" Width="150px"
DataSourceID="SqlDataSource3" DataTextField="Month" AutoPostBack="true"
DataValueField="Month" OnDataBound="MonthDropDownListDataBound"
onselectedindexchanged="MonthDropDownList_SelectedIndexChanged1">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:dbbilling2.0ConnectionString2 %>"
SelectCommand="SELECT [Month] FROM [tblMonth]"></asp:SqlDataSource>
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="MonthlyFeelabel" runat="server" Text="Monthly Fee" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:TextBox ID="txtMonthlyFee" runat="server" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator ID="MonthlyFeeValidator" runat="server"
ControlToValidate="txtMonthlyFee" CssClass="style3">*</asp:RequiredFieldValidator>
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="TransportFeelabel" runat="server" Text="Transport Fee" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:TextBox ID="txtTransportFee" runat="server" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator ID="TransportationFeeValidator" runat="server"
ControlToValidate="txtTransportFee" CssClass="style3">*</asp:RequiredFieldValidator>
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="Hostelfeelabel" runat="server" Text="Hostel Fee" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:TextBox ID="txtHostelFee" runat="server" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator ID="HostelFeeValidator" runat="server"
ControlToValidate="txtHostelFee" CssClass="style3">*</asp:RequiredFieldValidator>
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="ECAFeeLabel" runat="server" Text="ECA Fee" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:TextBox ID="txtECAFee" runat="server" Width="150px"></asp:TextBox>
<asp:RequiredFieldValidator ID="ECAFeeValidator" runat="server"
ControlToValidate="txtECAFee" CssClass="style3">*</asp:RequiredFieldValidator>
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:300px; vertical-align:top;" align="left" >
<asp:Label ID="DueFromPreviousMonthLabel" runat="server"
Text="Due From Previous Month" CssClass="style2"></asp:Label>
<br />
</td>
<td valign="top" align="center">
<asp:TextBox ID="txtDueFromPreviousMonth" runat="server" Width="150px" Text="0"></asp:TextBox>
<asp:RequiredFieldValidator ID="DueFromPreviousMonthValidator" runat="server"
ControlToValidate="txtECAFee" CssClass="style3">*</asp:RequiredFieldValidator>
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="TotalFeeLabel" runat="server" Text="Total Fee" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:TextBox ID="txtTotalFee" runat="server" Width="150px" ReadOnly="true"></asp:TextBox>
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
<asp:Label ID="PaidLabel" runat="server" Text="Paid" CssClass="style2"></asp:Label>
</td>
<td valign="top" align="center">
<asp:CheckBox ID="ChkPaidLabel" runat="server" />
<br />
<br />
<br />
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" >
</td>
<td valign="top" align="right">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="150px"
onclick="btnSubmit_Click" />
<asp:Button ID="btnReset" runat="server" Text="Reset" Width="150px" />
<asp:Button ID="btnCreateBill" runat="server" Text="CreateBill" Width="150px"
OnClick="btnCreateBill_Click"/>
<%--<asp:PopupControlExtender ID="btnCreateBill_PopupControlExtender" OffsetX="-1100" OffsetY="115"
runat="server" DynamicServicePath="" Enabled="True" ExtenderControlID=""
TargetControlID="btnCreateBill" PopupControlID="UpdatePanel1">
</asp:PopupControlExtender>--%>
</td>
</tr>
<tr>
<td style="width:150px; vertical-align:top;" align="left" colspan="2" >
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ModalPopupExtender ID="ModalPopUpExtender1" runat="server" PopupControlID="UpdatePanel1"
TargetControlID="UpdatePanel1" DropShadow="false" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>
<rsweb:ReportViewer ID="ReportingForPrintingReportViewer" runat="server" Visible="false" CssClass="panel"
Width="100%" Height="100%" Font-Names="Verdana" Font-Size="8pt"
InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Report.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetData" TypeName="DataSet1TableAdapters.tblTotalFeeTableAdapter">
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</asp:Content>
and this is my cs page:
protected void btnCreateBill_Click(object sender, EventArgs e)
{
ModalPopUpExtender1.Show();
DisplayReport();
}
Why isn't UpdatePanel1 being displayed when we click btnCreateBill?? I want to show UpdatePanel1 as popup when i click btnCreateBill
When I placed modal pop up extender inside my updatepanel1 it gave the error
An extender can't be in a different UpdatePanel than the control it extends.
Because its outside the updatepanel, bring it inside the update panel to make it appear. You cannot access and change state of controls outside update panel when a event is fired in the update panel.
When a event is fired in a update panel, only controls in the update panel can be accessed and modified.
<td style="width:150px; vertical-align:top;" align="left" colspan="2" >
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ModalPopupExtender ID="ModalPopUpExtender1" runat="server" PopupControlID="UpdatePanel1" TargetControlID="UpdatePanel1" DropShadow="false" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>
<rsweb:ReportViewer ID="ReportingForPrintingReportViewer" runat="server" Visible="false" CssClass="panel"
Width="100%" Height="100%" Font-Names="Verdana" Font-Size="8pt"
InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Report.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource2" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetData" TypeName="DataSet1TableAdapters.tblTotalFeeTableAdapter">
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</td>
instead of using updatepanel on modalpopup panel you can try something from code behind to serve the purpose.
<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
CancelControlID="btnCancel" PopupControlID="Panel1"
TargetControlID="HiddenField1">
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="Panel">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="34px" RepeatDirection="Horizontal"
Width="129px" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem>Option1</asp:ListItem>
<asp:ListItem>Option2</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txt1" runat="server"
Visible="False"></asp:TextBox>
<asp:TextBox ID="txt2" runat="server"
Visible="False"></asp:TextBox>
</asp:Panel>
===========================================
Code Behind:
===========================================
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedIndex == 0)
{
txt1.Visible = true;
ModalPopupExtender1.Show();
}
else
{
txt2.Visible = true;
ModalPopupExtender1.Show();
}
}

Add Master Page form values not returning on request.form

UPDATED ISSUE:
I converted some pages to use master pages and they worked fine.
When doing request.form on child page (form declaration is in master page) I get a null value (just doing Request.Form("field") returns NULL but before master pages it worked
NOTE: ALL the code worked fine before implementing master pages!!
The button code is:
<asp:Button ID="btnPACheck" runat="server" Text="<%$Resources:share,btnPACheck %>" onclick="btnPACheck_Click" />
The view soruce on the html page for the button is:
<input type="submit" name="ctl00$ContentPlaceHolder1$btnPACheck" value="Continue" id="ctl00_ContentPlaceHolder1_btnPACheck" />
The onclick code is long but it is declared like this (and first line has the debug line placed on it and it is not getting to it):
protected void btnPACheck_Click(object sender, EventArgs e)
{
bool validPA = false;
Master page is below:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPageSiteWide.master.cs" Inherits="MasterPageSiteWide" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register src="~/ucBanner.ascx" TagName="Banner" TagPrefix="ucBanner" %>
<!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>
<style type="text/css">
body {
background: url(page-bg.gif) repeat-x top left #5997C8;
CLIP: rect(19px 65px 50px 10px);
margin-top: 10px;
margin-bottom:30px;
margin-right: 40px;
margin-left: 60px;
width:80%;
}
TD.bluerow {
height: .10pc;
background-color: #000066;
}
TD.medbluerow {
height: .0005pc;
background-color: #6699CC;
}
.panel_with_padding {
padding-top:10px;
padding-left:10px;
padding-right:10px;
padding-bottom:10px;
}
</style>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server" method="post">
<asp:ScriptManager ID="ScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server"></asp:ScriptManager>
<asp:RoundedCornersExtender Corners="All" TargetControlID="MainPanel" BorderColor="Black" ID="RoundedCornersExtender1" runat="server"></asp:RoundedCornersExtender>
<asp:Panel BackColor="White" runat="server" ID="MainPanel" CssClass="panel_with_padding">
<div>
<br />
<div>
<asp:Label ID="lblTopHeading" runat="server" Font-Bold="true" Font-Size="X-Large" Text=""></asp:Label>
</div>
<br />
<ucBanner:Banner ID="bannerStrip" runat="server"></ucBanner:Banner>
<br />
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<br /><br />
<hr />
<div>
© Copyright 20xx-2012, Ford Motor Company. All rights reserved.
</div>
</asp:Panel>
</form>
</body>
</html>
Content page (part of cant post whole thing too long) where button is:
<%# Page Language="C#" MasterPageFile="~/MasterPageSiteWide.master" AutoEventWireup="true" CodeFile="initial.aspx.cs" ValidateRequest="false" Inherits="initial" UICulture="auto"%>
<%# MasterType virtualPath="~/MasterPageSiteWide.master"%>
<%# Register src="~/ucBanner.ascx" TagName="Banner" TagPrefix="ucBanner" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title>Hotline - Dealer Prior Approval - Begin</title>
<link href="Styles/dpaStyles.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function OpenPopUp() {
window.open("collectvin.aspx", "List", "scrollbars=no,resizable=no,width=400,height=350");
}
function InvokePop(vin) {
val = document.getElementById(vin).value;
// to handle in IE 7.0
if (window.showModalDialog) {
retVal = window.showModalDialog("collectvin.aspx?Control1=" + vin + "&ControlVal=" + val, 'Show Popup Window', "dialogHeight:90px,dialogWidth:250px,resizable:yes,center:yes,");
document.getElementById(vin).value = retVal;
}
}
function checkChoice() {
var hasFound = false
for (i = 0; i < document.secpaform.SecPACode.length; i++) {
if (document.secpaform.SecPACode[i].checked == true) {
hasFound = true
break;
}
}
if (!hasFound) {
alert("Please select one...")
document.secpaform.SecPACode[0].focus();
return false
}
else
return true
}
function checkOldVin() {
//alert('inside checkOldVin');
if (frmInitial.txtOldVin.value == '') {
alert('Please enter the VIN for an older vehicle!!!');
frmInitial.txtOldVin.focus();
return false;
}
var alphanumeric = /^[0-9a-zA-Z]+$/;
if (!frmInitial.txtOldVin.value.match(alphanumeric)) {
alert('VIN must be numbers and letters only!');
frmInitial.txtOldVin.focus();
return false;
}
return true;
}
function checkPartChoice() {
//alert('in checkPartsChoice');
}
</script>
<style type="text/css">
body {
background: url(page-bg.gif) repeat-x top left #5997C8;
CLIP: rect(19px 65px 50px 10px);
margin-top: 10px;
margin-bottom:30px;
margin-right: 40px;
margin-left: 60px;
width:80%;
}
TD.bluerow {
height: .10pc;
background-color: #000066;
}
TD.medbluerow {
height: .0005pc;
background-color: #6699CC;
}
p.MsoNormal
{margin-top:0in;
margin-right:0in;
margin-bottom:10.0pt;
margin-left:0in;
line-height:115%;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!-- -------------------------->
<!-- start outer table, rounded corners -->
<!-- -------------------------->
<table style="width: 95%;" align="center" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="8" height="11" bgcolor="#ffffff"><img src="images/ccbackground/HLEFT.jpg" alt=""/></td>
<td bgcolor="#ffffff" background="images/ccbackground/TOPbg.jpg"><img src="images/ccbackground/TOPbg.jpg" alt=""/></td>
<td width="8" height="11" bgcolor="#ffffff"><img src="images/ccbackground/HRIGHT.jpg" alt=""/></td>
</tr>
<tr>
<td width="8" background="images/ccbackground/LEFTbg.jpg"><img src="images/ccbackground/LEFTbg.jpg" alt=""/></td>
<td align="center" height="800" valign="top" bgcolor="white" >
<div>
<asp:Label ID="lblTopHeading" runat="server" Font-Bold="true" Font-Size="X-Large" Text="<%$Resources:share,lblTopHeading %>" EnableViewState="false"></asp:Label>
</div>
<!-- -------------------------->
<!-- begin main page content -->
<!-- -------------------------->
<asp:UpdatePanel ID="tryUP" runat="server">
<ContentTemplate>
<table width="100%" align="center" style="font-size:14px; font-family:Verdana,Arial;">
<tr align="center">
<td align="center" >
<br />
<ucBanner:Banner ID="bannerStrip" runat="server"></ucBanner:Banner>
<asp:LinkButton ID="LinkButton1" Text="English" Visible="false" runat="server" onclick="LinkButton1_Click"></asp:LinkButton><br />
<asp:Label ID="Label22" runat="server" Font-Size="Small" Text="<%$Resources:share,lblpartstatement %>" EnableViewState="false"></asp:Label>
<br />
<asp:LinkButton ID="LinkButton2" Text="<%$Resources:share,lblPartsList %>" Visible="true" runat="server" ></asp:LinkButton>
<br />
</td>
</tr>
<tr>
<td style="font-size:10px; padding-left:130px;">
<asp:Label ID="lblInitialHeading" runat="server" Font-Bold="true" Text="" EnableViewState="false"></asp:Label>
</td>
<td align="center" valign="top">
<asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="Large" Text=""></asp:Label>
</td>
</tr>
<tr align="center">
<td align="center">
<div id="Div1" class="example1" runat="server" visible="true" >
<a href="javascript:window.close();" style="color:Red; float:right">
<span>
<asp:Label ID="lblClose" Font-Names="Verdana" Font-Size="Medium" runat="server" Text="<%$ Resources:share,lblClose %>"></asp:Label>
</span>
</a>
</div>
</td>
</tr>
<tr align="center">
<td align="center" valign="top" style="font-size:16px; font-family:Verdana,Tahoma; font-weight:bold">
<div id="divButtons" runat="server" visible="true" >
<asp:Label ID="lblPAtypeheading" runat="server" Font-Names="Verdana" Text="<%$ Resources:share,lblPAtypeheading %>"></asp:Label> <asp:Label ID="lblPAtype" Font-Names="Verdana" runat="server" Font-Underline="true" Text=""></asp:Label>
</div>
</td>
</tr>
</table>
<br />
<div id="divPAnotrequired" runat="server" visible="false">
<asp:Label ID="lblNotRequired" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblPANotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divRADnotrequired" runat="server" visible="false">
<asp:Label ID="Label5" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblRADNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divCHMSLnotrequired" runat="server" visible="false">
<asp:Label ID="Label7" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblCHMSLNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divTaurusRearLampNotRequired" runat="server" visible="false">
<asp:Label ID="Label11" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblTaurusRearLampNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divRangerChatterNotRequired" runat="server" visible="false">
<asp:Label ID="Label15" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblRangerChatterNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divFlexSqueakNotRequired" runat="server" visible="false">
<asp:Label ID="Label16" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblFlexSqueakNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divEscapeNoiseNotRequired" runat="server" visible="false">
<asp:Label ID="Label17" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblEscapeNoiseNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divFiestaGlassNotRequired" runat="server" visible="false">
<asp:Label ID="Label18" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblFiestaGlassNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divScratchesNotRequired" runat="server" visible="false">
<asp:Label ID="Label20" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblScratchesNotRequired %>" EnableViewState="false"></asp:Label>
<br />
</div>
<div id="divCostCap" runat="server" visible="false">
<asp:Label ID="lblCostCap" runat="server" Font-Size="Medium" Font-Names="Verdana" ForeColor="IndianRed" Font-Bold="true" Text="<%$Resources:share,lblCostCap %>" EnableViewState="false"></asp:Label>
<div id="closeButtonDiv" class="closeButton" runat="server" visible="true" >
</div>
</div>
<div id="divRadMileage" runat="server" visible="false">
<div class="medBlueRow" style="width:700px; height:2px;"></div>
<table width="90%" align="center" style="font-size:14px; font-family:Verdana,Arial;">
<tr>
<td style="font-size:16px; font-family:Verdana,Tahoma; font-weight:bold">
<asp:Label ID="Label4" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblRadMileage %>" EnableViewState="false"></asp:Label>
</td>
</tr>
<tr>
<td align="center" style="font-size:12px; font-family:Verdana,Tahoma; font-weight:bold" height="125" valign="middle">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="btnIndexchange_Click" AutoPostBack="True">
<asp:ListItem Text="<%$Resources:share,lblYes %>" Value="yes"></asp:ListItem>
<asp:ListItem Text="<%$Resources:share,lblNo %>" Value="no"></asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Button ID="Button1" runat="server" Visible="false" Text="<%$Resources:share,btnDslParts %>" />
<br /><br />
</td>
</tr>
</table>
</div>
<div id="divCHMSL" runat="server" visible="false">
<table width="90%" align="center" style="font-size:14px; font-family:Verdana,Arial;">
<tr>
<td style="font-size:16px; font-family:Verdana,Tahoma; font-weight:bold">
<asp:Label ID="Label6" runat="server" Font-Names="Verdana" Text="<%$Resources:share,lblCHMSL %>" EnableViewState="false"></asp:Label>
</td>
</tr>
<tr>
<td align="center" style="font-size:12px; font-family:Verdana,Tahoma; font-weight:bold" valign="middle">
<asp:RadioButtonList ID="RadioButtonList2" runat="server" OnSelectedIndexChanged="btnIndexchangeCHMSL_Click" AutoPostBack="True">
<asp:ListItem Text="<%$Resources:share,lblCHMSLYes %>" Value="yes"></asp:ListItem>
<asp:ListItem Text="<%$Resources:share,lblCHMSLNo %>" Value="no"></asp:ListItem>
</asp:RadioButtonList>
Found Solution: Found the issue.
The form was doing Request. Form and that was returning NULL for all the values.
I just changed it to do the formfield.value instead of request.form("FormField")
This solved the issue.
Sorry for initial confusion on what the initial issue was.

Can't assign values to the textbox inside a Panel

As written in the title I have problems assigning values to the textbox inside a panel. The problem is that a button from gvAsseti doesn't show the pnlAsset (which has textboxes in it) and doesn't load the values into the textboxes.
What is strange is that code executes fine and while using debugger I was able to see that correct values are sent to the textboxes, but for some reason they aren't displayed (all I get are empty textboxes).
Here is the codefront (sorry for the length, you can skip the middle part, it has only textboxes):
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<uc:Firma ID="ucFirma" runat="server"></uc:Firma>
<asp:GridView ID="gvKontakti" runat="server" OnRowCommand="gvKontakti_RowCommand"
DataKeyNames="idKontakt">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnShowAssets" runat="server" CommandArgument='<%# Eval("idKontakt") %>'
CommandName="ShowAssets" Text="Prikaži assete" />
<asp:Button ID="btnAddAsset" runat="server" CommandArgument='<%# Eval("idKontakt") %>'
CommandName="AddAsset" Text="Dodaj asset" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="idKontakt" HeaderText="ID" Visible="false" />
<asp:BoundField DataField="Naziv" HeaderText="Naziv" />
</Columns>
</asp:GridView>
<asp:Panel ID="pnlAsset" runat="server">
<table>
<tr>
<td>
Naziv:
</td>
<td colspan="3">
<asp:TextBox ID="txtNaziv" runat="server" Width="430px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Kod 1:
</td>
<td>
<asp:TextBox ID="txtKod1" runat="server"></asp:TextBox>
</td>
<td>
Kod 2:
</td>
<td>
<asp:TextBox ID="txtKod2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Datum isteka garancije:
</td>
<td>
<asp:TextBox ID="txtGarancija" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Lokacija:
</td>
<td colspan="3">
<asp:TextBox ID="txtLokacija" runat="server" TextMode="MultiLine" Width="455px" Height="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Opis:
</td>
<td colspan="3">
<asp:TextBox ID="txtOpis" runat="server" TextMode="MultiLine" Width="455px" Height="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Aktivna imovina:
</td>
<td>
<asp:CheckBox ID="chkAktivna" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Spremi" OnClick="btnSave_Click" />
</td>
</tr>
</table>
</asp:Panel>
<asp:UpdatePanel ID="upAsseti" runat="server">
<ContentTemplate>
<asp:GridView ID="gvAsseti" runat="server" onrowcommand="gvAsseti_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnShowAsset" runat="server" CommandArgument='<%# Eval("idAsset") %>'
CommandName="ShowAsset" Text="Prikaži asset" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
And also the codebehind:
protected void gvAsseti_RowCommand(object sender, GridViewCommandEventArgs e)
{
int idFirma = Convert.ToInt32(Request.QueryString["idt"]);
int idAsset = Convert.ToInt32(e.CommandArgument);
TicketingSystemEntities db = new TicketingSystemEntities();
if (e.CommandName=="ShowAsset")
{
var asset = (from a in db.Assets
where a.idAsset == idAsset
select a).SingleOrDefault();
pnlAsset.Visible = true;
txtGarancija.Text = asset.DatumGarancije.ToString();
txtKod1.Text = asset.Kod1;
txtKod2.Text = asset.Kod2;
txtLokacija.Text = asset.Lokacija;
txtNaziv.Text = asset.Naziv;
txtOpis.Text = asset.Opis;
if (asset.Aktivan == true)
{
chkAktivna.Checked = true;
}
else
{
chkAktivna.Checked = false;
}
}
}
}
Any help would be appreciated.
Put the panel inside the updatepanel contenttemplate. As gvAsseti's inside an updatepanel, therefore it'll be refreshing the contents of the updatepanel on postback.

Resources