radio button in gridview template field - c#

I am making a exam web application in ASP.NET. I am using grid-view for showing question and the possible answers. I set size of grid view is 1 so it display only one question on a page-index. I am using radio button for multiple choice option.
When I select a radio button and going to next question or next page index of grid-view and come again previous question then I see that the radio button which I selected previously is not selected. What should I do for this?
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1"
GridLines="None" Height="380px"
onpageindexchanging="GridView1_PageIndexChanging"
onprerender="GridView1_PreRender" onrowcommand="GridView1_RowCommand"
OnRowDataBound="GridView1_RowDataBound"
onselectedindexchanged="GridView1_SelectedIndexChanged" PageSize="1"
ShowHeader="False" style="margin-right: 0px; margin-bottom: 0px;"
Width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table style=" width:100%; height: 550px;">
<tr>
<td class="style6" colspan="2" colspan="3"
style="border-width: 1px; border-bottom-style: inset;">
<asp:Label ID="Label14" runat="server" Font-Size="Large" Text="Question No :-"></asp:Label>
<asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Size="Large"
Text='<%# Eval("id") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="style4" colspan="2" colspan="2">
<asp:Label ID="Label15" runat="server" Font-Bold="True" Text="Question:-"
Font-Size="Large"></asp:Label>
<br /> <asp:Label ID="Label6" runat="server" Font-Bold="False"
Text='<%# Eval("Question") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="style9" style=" padding-top:10px">
A:-<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
Font-Bold="False"
oncheckedchanged="RadioButton1_CheckedChanged" Text='<%# Eval("A") %>' />
<br />
</td>
<td class="style1" rowspan="4" style=" padding-top:10px">
<asp:Image ID="Image1" runat="server" BorderStyle="None" Height="149px"
ImageUrl='<%# Eval("image") %>' Width="449px" />
</td>
</tr>
<tr>
<td class="style9">
B:-<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
Font-Bold="False"
oncheckedchanged="RadioButton2_CheckedChanged" Text='<%# Eval("B") %>' />
<br />
</td>
</tr>
<tr>
<td class="style9">
C:-<asp:RadioButton ID="RadioButton3" runat="server" AutoPostBack="True"
Font-Bold="False"
oncheckedchanged="RadioButton3_CheckedChanged" Text='<%# Eval("C") %>' />
<br />
</td>
</tr>
<tr>
<td class="style9">
D:-<asp:RadioButton ID="RadioButton4" runat="server" AutoPostBack="True"
Font-Bold="False"
oncheckedchanged="RadioButton4_CheckedChanged" Text='<%# Eval("D") %>' />
<br />
</td>
</tr>
<tr>
<td colspan="2">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Button ID="Button12" runat="server" BackColor="#006699" BorderStyle="None"
Font-Bold="True" Font-Size="Large" ForeColor="White" Height="34px"
Text="Next>>>" Width="230px" />
<asp:Button ID="Button2" runat="server" BackColor="#006699" BorderStyle="None"
CommandArgument='<%# Eval("id") %>' CommandName="Next" Font-Bold="True"
Font-Size="Large" ForeColor="White" Height="34px" Text="Mark for Review & Next"
Width="229px" />
<asp:Button ID="Button1" runat="server" BackColor="#006699" BorderStyle="None"
CommandArgument='<%# Eval("id") %>' CommandName="Save" Font-Bold="True"
Font-Size="Large" ForeColor="White" Height="34px" OnClick="Button1_Click"
Text="Save and Next" Width="230px" />
</td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemTemplate>
<table style=" width:100%; height: 550px;">
<tr>
<td class="style9" colspan="2">
Q<span ID="GridView1_ctl02_Label14" style="font-size:Large;">0</span> .
<span ID="GridView1_ctl02_Label6" style="font-size:Large;font-weight:bold;">abc</span>
</td>
</tr>
<tr>
<td class="style9">
C:-<span style="font-size:Large;font-weight:normal;"><input
ID="GridView1_ctl02_RadioButton3" name="GridView1$ctl02$RadioButton3"
onclick="javascript:setTimeout('__doPostBack(\'GridView1$ctl02$RadioButton3\',\'\')', 0)"
type="radio" value="RadioButton3" /><label
for="GridView1_ctl02_RadioButton3">abc</label></span>
<br />
</td>
<td class="style6" colspan="2"
style=" border-width: 1px; border-bottom-style: inset;">
A:-<span style="font-size:Large;font-weight:bold;"
ID="GridView1_ctl02_Label4"><input
ID="GridView1_ctl02_RadioButton1" name="GridView1$ctl02$RadioButton1"
onclick="javascript:setTimeout('__doPostBack(\'GridView1$ctl02$RadioButton1\',\'\')', 0)"
type="radio" value="RadioButton1" /><label
for="GridView1_ctl02_RadioButton1">abc</label></span>
<br />
</td>
<td class="style1" rowspan="4" style=" padding-top:10px">
<img ID="GridView1_ctl02_Image1" Src=""
style="border-style:None;height:98px;width:231px;border-width:0px;" />
</td>
</tr>
<tr>
<td class="style4" colspan="2">
B:-<span style="font-weight:bold;" ID="GridView1_ctl02_Label15"><input
ID="GridView1_ctl02_RadioButton2" name="GridView1$ctl02$RadioButton2"
onclick="javascript:setTimeout('__doPostBack(\'GridView1$ctl02$RadioButton2\',\'\')', 0)"
type="radio" value="RadioButton2" /><label
for="GridView1_ctl02_RadioButton2">abc</label></span>
<br />
</td>
</tr>
<tr>
</tr>
<tr>
<td class="style9">
D:-<span style="font-size:Large;font-weight:normal;"><input
ID="GridView1_ctl02_RadioButton3" name="GridView1$ctl02$RadioButton3"
onclick="javascript:setTimeout('__doPostBack(\'GridView1$ctl02$RadioButton3\',\'\')', 0)"
type="radio" value="RadioButton3" /><label
for="GridView1_ctl02_RadioButton4">abc</label></span>
<br />
</td>
</tr>
<tr>
<td colspan="2">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<input ID="GridView1_ctl02_Button12" name="GridView1$ctl02$Button12"
style="color:White;background-color:#006699;border-style:None;font-size:Large;font-weight:bold;height:34px;width:230px;"
type="submit" value="<<<Prv" /> <input
ID="GridView1_ctl02_Button2" name="GridView1$ctl02$Button2"
style="color:White;background-color:#006699;border-style:None;font-size:Large;font-weight:bold;height:34px;width:229px;"
type="submit" value="Mark and Next" />
<input ID="GridView1_ctl02_Button1" name="GridView1$ctl02$Button1"
style="color:White;background-color:#006699;border-style:None;font-size:Large;font-weight:bold;height:34px;width:230px;"
type="submit" value="Save and Next" />
</td>
</tr>
</table>
</AlternatingItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="White" BorderColor="White" ForeColor="White" />
</asp:GridView>

Save Answer in View-state using code
if (e.CommandName == "Save")
{
foreach (GridViewRow row in GridView1.Rows)
{
if (((RadioButton)row.FindControl("RadioButton1")).Checked)
{
Label12.Text = "A";
}
if (((RadioButton)row.FindControl("RadioButton2")).Checked)
{
Label12.Text = "B";
}
if (((RadioButton)row.FindControl("RadioButton3")).Checked)
{
Label12.Text = "C";
}
if (((RadioButton)row.FindControl("RadioButton4")).Checked)
{
Label12.Text = "D";
}
string m = Convert.ToString(e.CommandArgument);
ViewState[m] = Label12.Text;
}
Run a for Loop in Row Data Bound event of GridView1
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "id"));
int i, j;
for (i = 1; i <= 65; i++)
{
j = i + 100;
string k = i.ToString();
string l = j.ToString();
if (ViewState[l] != null)
{
if (id == k)
{
if (ViewState[l].ToString() == "A")
{
(e.Row.Cells[0].FindControl("RadioButton1") as RadioButton).Checked = true;
}
if (ViewState[l].ToString() == "B")
{
(e.Row.Cells[0].FindControl("RadioButton2") as RadioButton).Checked = true;
}
if (ViewState[l].ToString() == "C")
{
(e.Row.Cells[0].FindControl("RadioButton3") as RadioButton).Checked = true;
}
if (ViewState[l].ToString() == "D")
{
(e.Row.Cells[0].FindControl("RadioButton4") as RadioButton).Checked = true;
}
}
}
}
}
}
Solve !!!!!

Related

How to make first 2 tabs of radtabstrip mandatory to be filled out?

I have an ASP.NET project with telerik embedded.
The telerik control I have is RadTabStrip.
The current task is The customer wants the first 2 tabs "Employee" and "general info" to be fill out first before they are able to fill out the other tabs.
Not sure how to implement this. Here is a sample
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0" MultiPageID="RadMultiPage1"
Skin="Telerik" CausesValidation="false">
<Tabs>
<telerik:RadTab runat="server" Selected="True">
<TabTemplate>
<asp:Label ID="Label29" runat="server" Text="<%$ Resources:strings, sample_generalinformation %>" />
<img id="generalInfoErrorIndicator" src="../Images/alert-small.gif" alt="" style="display: none;" />
</TabTemplate>
</telerik:RadTab>
<telerik:RadTab runat="server">
Here is the tab code.
<!-- EMPLOYEE INFORMATION -->
<telerik:RadPageView ID="pvEmployeeInformation" runat="server">
<div id="employeeInfoDiv" runat="server">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td colspan="2">
<h1>
<asp:Label ID="Label34" runat="server" Text="<%$ Resources:strings, observed_employee_information %>" /></h1>
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label12" runat="server" Text="<%$ Resources:strings, employee_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:EmployeeSearch ID="employeeSearch" runat="server" OnClientEmployeeSelected="employeeSelected"
ClientValidationFunction="validateEmployee" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td>
<asp:CheckBox ID="areaSampleCheckBox" runat="server" Text="<%$ Resources:strings, labels_areasample %>"
ValidationGroup="employeeInfo" />
</td>
<td>
<asp:CheckBox ID="unknownEmployeeCheckBox" runat="server" Text="<%$ Resources:strings, labels_unknownemployee %>"
ValidationGroup="employeeInfo" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label13" runat="server" Text="<%$ Resources:strings, job_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:JobSearch ID="jobSearch" runat="server" ValidationGroup="employeeInfo" ClientValidationFunction="validateJob"
OnClientJobSelected="jobSelected" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:CheckBox ID="unknownJobCheckBox" runat="server" Text="<%$ Resources:strings, labels_unknownjob %>" />
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label14" runat="server" Text="<%$ Resources:strings, shift_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewShiftDropDown ID="shiftDropDown" runat="server" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label15" runat="server" Text="<%$ Resources:strings, shiftlength_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewShiftLengthDropDown ID="shiftLengthDropDown" runat="server" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:ValidationSummary ID="employeeInformationValidationSummary" runat="server" Font-Bold="True"
ForeColor="Red" HeaderText="<%$ Resources:strings, validationsummary_nextwizard_msg %>"
ValidationGroup="employeeInfo" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
And another
<!-- GENERAL INFORMATION -->
<telerik:RadPageView ID="pvGeneralInformation" runat="server">
<div id="generalInfoDiv" runat="server">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td colspan="4">
<h1>
<asp:Label ID="Label16" runat="server" Text="<%$ Resources:strings, general_information %>" /></h1>
</td>
</tr>
<tr valign="top">
<td style="text-align: right;">
<asp:Label ID="Label1" runat="server" Text="<%$ Resources:strings, facility_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:FacilitySearch ID="facilitySearch" runat="server" ValidationGroup="generalInfo"
OnClientFacilitySelected="facilitySelected" OnClientFacilityCleared="facilityCleared"
AutoPostBack="true" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label7" runat="server" Text="<%$ Resources:strings, samplelength_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleLengthDropDown ID="sampleLengthDropDown" runat="server" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;">
<asp:Label ID="Label2" runat="server" Text="<%$ Resources:strings, sampledate_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewDateEntry ID="sampleDate" runat="server" ValidationGroup="generalInfo"
ValidateDateNotInFuture="true" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label8" runat="server" Text="<%$ Resources:strings, samplemethod_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:SampleMethodSearch ID="sampleMethodSearch" runat="server" ValidationGroup="generalInfo"
OnClientSampleMethodSelected="sampleMethodSelected" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right;">
<asp:Label ID="Label3" runat="server" Text="<%$ Resources:strings, sampletype_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleTypeDropDown ID="sampleTypeDropDown" runat="server" ValidationGroup="generalInfo"
FormDesignator="PassiveBadge" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label69" runat="server" Text="<%$ Resources:strings, samplenumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="sampleNumberTextBox" runat="server" Skin="Telerik" Width="200px" /> <asp:Image
ID="sampleNumberInfoImage" runat="server" ImageUrl="~/Images/info.png" ToolTip="<%$ Resources:strings, samplenumber_info %>" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator19" runat="server"
ControlToValidate="sampleNumberTextBox" ErrorMessage="<%$ Resources:strings, validations_fieldlength_16 %>"
ToolTip="<%$ Resources:strings, validations_fieldlength_16 %>" ValidationExpression="<%$ AppSettings:Length16ValidationExpression %>"
ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label4" runat="server" Text="<%$ Resources:strings, occupationalhealthlimit_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:OelSearch ID="oelSearch" runat="server" ValidationGroup="generalInfo" OnClientOelSelected="oelSelected" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label10" runat="server" Text="<%$ Resources:strings, labsamplenumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="labSampleNumberTextBox" runat="server" Skin="Telerik" Width="175px" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="labSampleNumberTextBox"
ErrorMessage="<%$ Resources:strings, labsamplenumber_length %>" ToolTip="<%$ Resources:strings, labsamplenumber_length %>"
ValidationExpression="<%$ AppSettings:Length64ValidationExpression %>" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label67" runat="server" Text="<%$ Resources:strings, exposuregroup_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:ExposureGroupSearch ID="exposureGroupSearch" runat="server" ValidationGroup="generalInfo" />
</td>
<td colspan="2" align="center">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label11" runat="server" Text="<%$ Resources:strings, stelsample_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<asp:CheckBox ID="stelSampleCheckBox" runat="server" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label68" runat="server" Text="<%$ Resources:strings, labels_ceiling %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<asp:CheckBox ID="ceilingSampleCheckBox" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label5" runat="server" Text="<%$ Resources:strings, collectinguser_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:AdminUserSearch ID="adminUserSearch" runat="server" ValidationGroup="generalInfo" />
</td>
<td style="text-align: right;">
<asp:Label ID="Label18" runat="server" Text="<%$ Resources:strings, samplingdevice_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSamplingDeviceDropDown ID="samplingDeviceDropDown" runat="server" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label6" runat="server" Text="<%$ Resources:strings, samplestrategy_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleStrategyDropDown ID="sampleStrategyDropDown" runat="server" ValidationGroup="generalInfo" />
</td>
<td style="text-align: right;">
<asp:Label ID="Label19" runat="server" Text="<%$ Resources:strings, blanknumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="blankNumberTextBox" runat="server" Skin="Telerik" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="blankNumberTextBox"
ErrorMessage="<%$ Resources:strings, blanknumber_required %>" ToolTip="<%$ Resources:strings, blanknumber_required %>"
ValidationGroup="generalInfo" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="blankNumberTextBox"
ErrorMessage="<%$ Resources:strings, blanknumber_length %>" ToolTip="<%$ Resources:strings, blanknumber_length %>"
ValidationExpression="<%$ AppSettings:Length64ValidationExpression %>" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td colspan="4">
<asp:ValidationSummary ID="generalInformationValidationSummary" runat="server" Font-Bold="True"
ForeColor="Red" HeaderText="<%$ Resources:strings, validationsummary_nextwizard_msg %>"
ValidationGroup="generalInfo" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
It is very difficult to give you a solution based on your own code because of all the custom references. However, the controls in the various tabs can be accessed directly from code behind. I made a test on a 3 tabs RadTabStrip playing on enabling tab2.
UPDATE
Something went wrong with the previous example. I had to use some Javascript to resolve the issue on the client side. I tested this code and it is working. Basically there are two textboxes on the first tab and a button that is disabled by default. The button gets enabled only if text is in both textboxes (I understood you have more than one control on the tab that needs to be filled-in so this is a good example). Then clicking the button you enable tab 2. You can rewrite the javascript to enable directly the tabs when your fields/controls on the first and second tab are satisfying the requirements.
In PAGE_LOAD set the tabs that should not be visible or enabled
protected void Page_Load(object sender, EventArgs e)
{
//RadTabStrip1.Tabs[2].Visible = false;
RadTabStrip1.Tabs[2].Enabled = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
RadTabStrip1.Tabs[2].Enabled = true;
}
Here is the rest of the code with the script
<body>
<form id="form1" runat="server">
<script language="javascript" type="text/javascript">
//function to enable button if two textboxes contains text
function SetButtonStatus(sender, target) {
var first = document.getElementById('<%=TextBox1.ClientID %>');
var second = document.getElementById('<%=TextBox2.ClientID %>');
//Condition to check whether user enters text in two textboxes or not
if ((sender.value.length >= 1 && first.value.length >= 1) && (sender.value.length >= 1 && second.value.length >= 1))
document.getElementById(target).disabled = false;
else
document.getElementById(target).disabled = true;
}
</script>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<div>
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1" SelectedIndex="0" Skin="Silk">
<Tabs>
<telerik:RadTab Text="I am Tab 0" Width="200px"></telerik:RadTab>
<telerik:RadTab Text="I am Tab 1" Width="200px"></telerik:RadTab>
<telerik:RadTab Text="I am Tab 2" Width="200px"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0" CssClass="outerMultiPage">
<telerik:RadPageView runat="server" ID="RadPageView1">
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip2" MultiPageID="RadMultiPage2"
Orientation="VerticalLeft" Skin="Silk" Width="50px" Height="355px" SelectedIndex="0">
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage2" SelectedIndex="0" CssClass="innerMultiPage">
<telerik:RadPageView runat="server" ID="PageView1">
<div>
<asp:TextBox ID="TextBox1" runat="server" onkeyup="SetButtonStatus(this,'btnButton')"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onkeyup="SetButtonStatus(this,'btnButton')"></asp:TextBox>
<asp:Button ID="btnButton" runat="server" Text="Button" Enabled="false" OnClick="Button1_Click" />
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="RadPageView2">
<div></div>
<div>
<p>Something</p>
</div>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="RadPageView3">
<div>
<p>Again something</p>
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
</div>
</form>
</body>

Hidden Field in Gridview

I have hidden field in gridview. I do not get the value in code behind. It works fine without MasterPage and Ajax, can you help me to get a value in code behind.
Thanks
protected void empgrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "UpdateEmployee")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = empgrid.Rows[index];
Session["Employee"] = ((HiddenField)empgrid.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("EmployeeID")).Value;
Response.Redirect("UpdateEmployee.aspx");
}
}
<%# Page EnableEventValidation = "false" Title="" MasterPageFile="~/EmploymentWeb.Master" Language="C#" AutoEventWireup="true" CodeBehind="employeeborowes.aspx.cs" Inherits="Employment_Site.employeeborowes" %>
<asp:Content ID="Content1" ContentPlaceHolderID="AllContent" runat="server">
<table style="width: 100%">
<tr>
<td style="width: 105px">
<asp:Label ID="Label1" runat="server" Text="Employee Name"></asp:Label>
</td>
<td style="width: 178px">
<asp:TextBox ID="empname" runat="server" Width="165px"></asp:TextBox>
</td>
<td class="style2" style="width: 61px">
<asp:Button ID="btnsearch" runat="server" Text="Search" Width="70px"
onclick="btnsearch_Click" />
</td>
<td class="style2" style="width: 72px">
<asp:Button ID="btnclear" runat="server" onclick="btnclear_Click" Text="Clear"
Width="70px" />
</td>
<td style="width: 144px">
</td>
</tr>
<tr>
<td style="width: 105px">
</td>
<td colspan="4">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional" >
<ContentTemplate>
<asp:GridView ID="empgrid" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None" Width="303px"
onrowcommand="empgrid_RowCommand">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField Visible="False">
<ItemTemplate>
<asp:HiddenField ID="EmployeeID" runat="server" Value='<%# Eval("EmployeeID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FirstName" HeaderText="First Name" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnupdate" runat="server" Text="Update"
CommandName="UpdateEmployee" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td style="width: 105px">
</td>
<td style="width: 178px">
</td>
<td class="style2" style="width: 61px">
</td>
<td class="style2" style="width: 72px">
</td>
<td style="width: 144px">
</td>
</tr>
<tr>
<td style="width: 105px">
</td>
<td style="width: 178px">
</td>
<td class="style2" style="width: 61px">
</td>
<td class="style2" style="width: 72px">
</td>
<td style="width: 144px">
</td>
</tr>
</table>
</asp:Content>
Try this
GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
HiddenField empID = (HiddenField)row.FindControl("EmployeeID");
Session["Employee"] = empID.Value;
Try This:
Use Response.Redirect("UpdateEmployee.aspx",false);
instead of Response.Redirect("UpdateEmployee.aspx");
This is because of the way Redirect and session variables work.
When you create a new session an volatile cookie is set on the client that contains the session token. On all subsequent requests, and as long as the server session and the client cookie have not expired, ASP.NET can look at this cookie and find the right session.
what Redirect does is to send a special header to the client so that it asks the server for a different page than the one it was waiting for.
Hope this helps!!

how to pop up two modalpopup in gridview

I want to pop up two modalpopup from a gridview. I searched online but couldn't find the exact answer. Any help is appreciated.
--------ModalPopupExtender1---------
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
BackgroundCssClass="ModalPopupBG" CancelControlID="btn_Cancel" Drag="true"
PopupControlID="Panel2" PopupDragHandleControlID="Panel2"
TargetControlID="btnNew">
</asp:ModalPopupExtender>
-----------------PopupControlID="Panel2--------------------------
<div id="Panel2" class="popupConfirmation">
<div class="popup_Container">
<div id="PopupHeader" class="popup_Titlebar">
<div class="TitlebarLeft">
<%--
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
--%>
Edit Customer
</div>
<!--
<div class="TitlebarRight" >
</div>
-->
</div>
<div>
<table bgcolor="#CCFFFF" cellpadding="0" cellspacing="2" width="100%">
<tr>
<td width="5%">
</td>
<td width="25%">
</td>
<td width="65%">
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:LabelID="lblName"runat="server"FontSize="11pt" Text="First Name:">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtFirstName" runat="server" Width="300px">
</asp:TextBox>
<asp:Label ID="lbl_ErrorName" runat="server" ForeColor="Red"
style="display:none" Text="*">
</asp:Label>
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblName2" runat="server" Font-Size="11pt" Text="Second Name:">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtSecondName" runat="server" Width="300px">
</asp:TextBox>
</td>
<td width="5%">
</td>
</tr>
<%--
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="45%">
<asp:Label ID="lblName0" runat="server" Font-Size="11pt" Text="City">
</asp:Label>
</td>
<td style="text-align: left" width="45%">
<asp:TextBox ID="txtCity" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="45%">
<asp:Label ID="lblName1" runat="server" Font-Size="11pt" Text="State">
</asp:Label>
</td>
<td style="text-align: left" width="45%">
<asp:TextBox ID="txtState" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
<td width="5%">
</td>
</tr>
--%>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblAddress1" runat="server" Font-Size="11pt" Text="Address1:">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtAddress1" runat="server" Width="300px">
</asp:TextBox>
<asp:Label ID="lbl_ErrorAddress1" runat="server" ForeColor="Red"
style="display:none" Text="*">
</asp:Label>
</td>
<td width="5%">
</td>
</tr>
<%--
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="45%">
<asp:Label ID="lblAddress2" runat="server" Font-Size="11pt" Text="Address2:">
</asp:Label>
</td>
<td style="text-align: left" width="45%">
<asp:TextBox ID="txtAddress2" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
<td width="5%">
</td>
</tr>
--%>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblDOB" runat="server" Font-Size="11pt" Text="Phone">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtPhone" runat="server" Width="200px">
</asp:TextBox>
<%--
<asp:CalendarExtender ID="txt_DOB_CalendarExtender" runat="server"
TargetControlID="txt_DOB">
</asp:CalendarExtender>
--%>
<asp:Label ID="lblErrorDOB" runat="server" Font-Bold="True" ForeColor="Red"
style="display:none" Text="*">
</asp:Label>
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
<asp:Label ID="lblDOB0" runat="server" Font-Size="11pt" Text="Mobile">
</asp:Label>
</td>
<td style="text-align: left" width="65%">
<asp:TextBox ID="txtMobile" runat="server" Width="200px">
</asp:TextBox>
</td>
<td width="5%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td style="text-align: right" width="25%">
</td>
<td style="text-align: left" width="65%">
</td>
<td width="5%">
</td>
</tr>
</table>
</div>
<div align="center">
<asp:Button ID="btn_Update" runat="server"
Text="Save" Width="75px" onclick="btn_Update_Click" />
<asp:Button ID="btn_Cancel" runat="server" Text="Cancel" Width="75px" />
</div>
</div>
</div>
----------------`ModalpopUp`----------------------------
<asp:ModalPopupExtender ID="ModalPopUp" runat="server"
CancelControlID="idclose" Drag="true" DynamicServicePath="" Enabled="True"
PopupControlID="PartyCustomers_idbody"
PopupDragHandleControlID="PartyCustomers_IdTitle"
TargetControlID="btnShowPopup">
<Animations>
<OnShown><Fadein Duration="0.50" /></OnShown>
<OnHiding><Fadeout Duration="0.75" /></OnHiding>
</Animations>
</asp:ModalPopupExtender>
--------------------PartyCustomers_idbody : popupbody--------------
`<div id="PartyCustomers_idbody" runat="server" class="Common_divbody"
>
<div id="PartyCustomers_IdTitle" runat="server" class="Common_divtitle"
>
<div id="idclose" class="Common_close">
</div>
<div class="Common_divhr">
Booked Status</div>
</div>
<div class="ModalPopUpDiv">
<asp:Label ID="lblmessage1" runat="server" Text="Label"></asp:Label>
<asp:GridView ID="dgvSystemDetails" runat="server" AllowPaging="True"
AllowSorting="True" AlternatingRowStyle-CssClass="alt"
AutoGenerateColumns="False" CellSpacing="2" CssClass="mGrid" Font-Bold="True"
Font-Names="Arial" Font-Size="Small" PageSize="12"
Width="750px" DataKeyNames="SystemCode"
onrowdatabound="dgvSystemDetails_RowDataBound">
<AlternatingRowStyle CssClass="alt" />
<Columns>
<asp:BoundField DataField="RegistrationDate" DataFormatString="{0:d}"
HeaderText="Registration Date">
<HeaderStyle />
<ItemStyle />
</asp:BoundField>
<asp:BoundField DataField="SystemCode" HeaderText="System Code" />
<asp:BoundField DataField="Reg_Status" HeaderText="Reg. Status" />
<asp:BoundField DataField="Key" HeaderText="Key" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnBlock" runat="server" CssClass="Common_button"
Text="Block" onclick="btnBlock_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>`
--------------------------------cs-: RowCommand---code--------------------------
protected void dgvActivatedCustomers_RowCommand1(object sender, GridViewCommandEventArgs e)
{
//Load System details gridview in modalpop up...
if(e.CommandName=="Select")
{
DataSet ds;
int RowIndex = Convert.ToInt32(e.CommandArgument);
long ProductSerialID = Convert.ToInt32(dgvActivatedCustomers.DataKeys[RowIndex].Values["ProductSerialID"]) ;
hdnProuductId.Value= dgvActivatedCustomers.DataKeys[RowIndex].Values["ProductSerialID"].ToString();
lblmessage1.Visible = true;
//string RegStatus = dgvSystemDetails.SelectedRow.Cells[2].Text;
string ProductSerial = dgvActivatedCustomers.Rows[RowIndex].Cells[6].Text;
string Reg_Status = LoadSystemDetails(ProductSerialID).Tables[0].Rows[0]["Reg_Status"].ToString();
lblmessage1.Text = "Activation Code :" + General.GetActivationCode(Convert.ToDouble(ProductSerial)).ToString();
LoadSystemDetails(ProductSerialID);
ds = LoadSystemDetails(ProductSerialID);
//filling data table
DataTable dt = (DataTable)dgvSystemDetails.DataSource;
//Add new columns to datatable
dt.Columns.Add("Key", typeof(System.Int64));
// get key for specific key by passing system code ot getRegistrationKey.
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string SystemCode = ds.Tables[0].Rows[i]["SystemCode"].ToString();
//lblmessage2.Text = "Key :" + Registration.getRegistrationKey(SystemCode, ProductSerial);
string Key = Registration.getRegistrationKey(SystemCode, ProductSerial);
dt.Rows[i]["Key"] = Key;
}
Session["dgvSystemDetailsDataSource"] = dt;
dgvSystemDetails.DataSource = dt;
dgvSystemDetails.DataBind();
dgvSystemDetails.Visible = true;
if (Reg_Status == "Blocked")
{
lblmessage1.Visible = true;
lblmessage1.Text = "Blocked System";
//dgvSystemDetails.FindControl("btnBlock").Visible = false;
dgvSystemDetails.DataSource = Session["dgvSystemDetailsDataSource"];
dgvSystemDetails.DataBind();
ModalPopUp.Show();
}
ModalPopUp.Show();
}
}
description :btnclick second popup--------------
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
int rowno = row.RowIndex;
txtFirstName.Text = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerName"].ToString();
txtSecondName.Text = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerLName"].ToString();
txtAddress1.Text = (dgvActivatedCustomers.Rows[rowno].Cells[4].Text != " " ? dgvActivatedCustomers.Rows[rowno].Cells[4].Text : "");
txtPhone.Text = (dgvActivatedCustomers.Rows[rowno].Cells[2].Text != " " ? dgvActivatedCustomers.Rows[rowno].Cells[2].Text : "");
txtMobile.Text = (dgvActivatedCustomers.Rows[rowno].Cells[3].Text != " " ? dgvActivatedCustomers.Rows[rowno].Cells[3].Text : "");
hdnId.Value = dgvActivatedCustomers.DataKeys[rowno].Values["CustomerID"].ToString();
txtName.Text = (dgvDemoCust.SelectedRow != "") ? dgvDemoCust.SelectedRow.Cells[0].Text : "";
ModalPopupExtender1.Show();
}
catch (Exception ex) { }
}
Question : The first pop up is showing but the second one doesn't.....any body have any idea

Ajax TabPanels trigger validation for other tabs in ASP.Net 4.0

I have Ajax TabPanel with Tab "Employee List" "Add Employee" "Edit Employee"
On Employee List Tab i use gridview to display list of employee along with link Button to view details of employee on same tab and "Del" button to delete employee. It worked fine but when i added Controls to Second tab "Add Employee" along with validation controls. After this gridview in Tab one is not working as it trigger validation on second Tab.
How can i stop this validation which is triggered by controls on Tab 1
Below is the code
<asp:TabContainer ID="TabContainer1" runat="server" Height="320px" Width="100%"
ActiveTabIndex="0" >
<asp:TabPanel ID="atpEmployeeList" runat="server" >
<HeaderTemplate>Employee List</HeaderTemplate>
<ContentTemplate>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="style1" align="left" valign="top">
<b>Employee List</b>
<asp:GridView ID="gvEmployeeList" runat="server" AutoGenerateColumns="False"
DataKeyNames="eCode" BackColor="White" BorderColor="#336666"
BorderStyle="None" BorderWidth="2px" CellPadding="4"
GridLines="Horizontal" onrowcommand="gvEmployeeList_RowCommand"
onrowdatabound="gvEmployeeList_RowDataBound" >
<Columns>
<asp:BoundField DataField="eSno" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="eSno" />
<asp:BoundField DataField="eFirstName" HeaderText="First Name"
SortExpression="eFirstName" />
<asp:BoundField DataField="eLastName" HeaderText="Last Name"
SortExpression="eLastName" />
<asp:BoundField DataField="eDepartment" HeaderText="Department"
SortExpression="eDepartment" />
<asp:BoundField DataField="eSalary" HeaderText="Salary"
SortExpression="eSalary" />
<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEmpDetails" CommandArgument='<%# Eval("eSno") %>' CommandName="ViewDetails" runat="server">
View</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEmpDelete" CommandArgument='<%# Eval("eSno") %>' CommandName="Delete" runat="server">
Del</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336699" ForeColor="White" HorizontalAlign="Right" />
<RowStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#487575" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#275353" />
</asp:GridView>
</td>
<td width="250px" align="left" valign="top">
<b>Employee Details</b>
<br />
<table width="280px" align="left" cellpadding="3" cellspacing="0" >
<tr>
<td class="style8" bgcolor="#336699">
Code</td>
<td>
<asp:Label ID="lblEmpCode" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Fisrt Name</td>
<td>
<asp:Label ID="lblFirstName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" bgcolor="#336699">
Last Name</td>
<td class="style6">
<asp:Label ID="lblLastName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Designation</td>
<td>
<asp:Label ID="lblDesignation" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Department</td>
<td>
<asp:Label ID="lblDepartment" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Salary</td>
<td>
<asp:Label ID="lblSalary" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Join Date</td>
<td>
<asp:Label ID="lblJoinDate" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Phone</td>
<td>
<asp:Label ID="lblPhone" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
Address</td>
<td>
<asp:Label ID="lblAddress" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style8" bgcolor="#336699">
City</td>
<td>
<asp:Label ID="lblCity" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style4">
</td>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="atpAddEmployee" runat="server" >
<HeaderTemplate>Add Employee</HeaderTemplate>
<ContentTemplate>
<div><b>Enter Details of New Employee</b></div>
<table border="0px"><tr>
<td width="400px">
<div class="spacer"></div>
<div class="row">
<asp:Label ID="lblAEmpCode" CssClass="txtLabel" runat="server" Text="Code :"></asp:Label>
<asp:TextBox ID="txtACode" runat="server" CssClass="txt4Digit"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCode" runat="server" ErrorMessage="*"
ControlToValidate="txtACode"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblAFN" CssClass="txtLabel" runat="server" Text="First Name :"></asp:Label>
<asp:TextBox ID="txtAFN" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ControlToValidate="txtAFN"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblALN" CssClass="txtLabel" runat="server" Text="Last Name :"></asp:Label>
<asp:TextBox ID="txtALN" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="txtALN"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblADesignation" CssClass="txtLabel" runat="server" Text="Designation :"></asp:Label>
<asp:TextBox ID="txtADesignation" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
ControlToValidate="txtADesignation"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblADepartment" CssClass="txtLabel" runat="server" Text="Department :"></asp:Label>
<asp:TextBox ID="txtADepartment" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
ControlToValidate="txtADepartment"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblASalary" CssClass="txtLabel" runat="server" Text="Salary :"></asp:Label>
<asp:TextBox ID="txtASalary" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*"
ControlToValidate="txtASalary"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblAJoinDate" CssClass="txtLabel" runat="server" Text="Join Date :"></asp:Label>
<asp:TextBox ID="txtAJoinDate" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
ControlToValidate="txtAJoinDate"></asp:RequiredFieldValidator>
</div>
</td>
<td width="400px">
<div class="spacer"></div>
<div class="row">
<asp:Label ID="lblAAddress" CssClass="txtLabel" runat="server" Text="Address :"></asp:Label>
<asp:TextBox ID="txtAAddress" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="*"
ControlToValidate="txtAAddress"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblACity" CssClass="txtLabel" runat="server" Text="City :"></asp:Label>
<asp:TextBox ID="txtACity" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="*"
ControlToValidate="txtACity"></asp:RequiredFieldValidator>
</div>
<div class="row">
<asp:Label ID="lblACountry" CssClass="txtLabel" runat="server" Text="Country :"></asp:Label>
<asp:UpdatePanel ID="updatepanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddCountry" runat="server" CssClass="ddGeneral" DataTextField="Country"
DataValueField="CountryId" OnSelectedIndexChanged="ddCountry_SelectedIndexChanged"
AutoPostBack="true" AppendDataBoundItems="true" >
<asp:ListItem Value="0">Select Country</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="row">
<asp:Label ID="lblAState" CssClass="txtLabel" runat="server" Text="State :"></asp:Label>
<asp:UpdatePanel ID="updatePnlState" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddState" runat="server" CssClass="ddGeneral" DataTextField="Region" DataValueField="RegionId" AppendDataBoundItems="true">
<asp:ListItem Value="0">Select State</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="updProgLoading" runat="server" >
<ProgressTemplate>
<img src="images/ajax-loader-small.gif" align="left" alt="Loading..." vspace="0" />
</ProgressTemplate>
</asp:UpdateProgress>
</div>
<div class="row">
<asp:Label ID="lblALL" CssClass="txtLabel" runat="server" Text="Landline :"></asp:Label>
<asp:TextBox ID="txtALL" runat="server" CssClass="txtbox"></asp:TextBox>
</div>
<div class="row">
<asp:Label ID="lblAMobile" CssClass="txtLabel" runat="server" Text="Mobile :"></asp:Label>
<asp:TextBox ID="txtAMobile" runat="server" CssClass="txtbox"></asp:TextBox>
</div>
<div class="row">
<asp:Label ID="lblAEmail" CssClass="txtLabel" runat="server" Text="Email :"></asp:Label>
<asp:TextBox ID="txtAEmail" runat="server" CssClass="txtbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="*"
ControlToValidate="txtAEmail"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr><td colspan="2" align="center" height="40px">
<asp:Button ID="btnAddEmployee" runat="server" Text="Add Employee"
CssClass="btn" onclick="btnAddEmployee_Click" /> <input id="Reset1" type="reset" class="btn" value="Reset" />
</td></tr>
</table>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="atpEditEmployee" runat="server" >
<HeaderTemplate>Edit Employee</HeaderTemplate>
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<input id="Button2" type="button" value="Next" onclick="MoveTab(1)" />
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
You should look at utilising the ValidationGroup attribute for validators. For example for all the validators in the atpAddEmployee tab you would set the attribute like so ValidationGroup="atpAddEmployee" or any other name that you think appropriate.
I've taken one of the validators from the atpAddEmployee tab and added the attribute as described above.
<asp:RequiredFieldValidator ID="rfvCode" runat="server" ErrorMessage="*" ControlToValidate="txtACode" ValidationGroup="atpAddEmployee"></asp:RequiredFieldValidator>
For that particular tab you would also need to add the ValidationGroup attribute to the button that should trigger the validation, see below.
<asp:Button ID="btnAddEmployee" runat="server" Text="Add Employee" CssClass="btn" onclick="btnAddEmployee_Click" ValidationGroup="atpAddEmployee" />
Some further reading, MSDN and W3Schools.

modal popup extender problem

i use modal popup extender to show my details in another separate window it is a panel contains some controls the problem is ::
when i click on my button which contains::
the Show() method the parent page just frozen and no popup appears at all on the other side i have a grid view when i click on the last button on it the popup appears where the other buttons on the grid view make the same behavior of my first button , i donot know what is the problem my panel visibility = true and no setting in my behind code..i view the source and i find the panel with its contents then why the popup window doesnot appear..i search alot but i donot find a solution to my problem ..
my aspx::
<asp:Panel id="master_editMode" runat="server" >
<div id="masterDiv" style="width:98%" dir="rtl">
<div id="masterControls" align="center">
<table border="0" width="98%">
<tr>
<td align="center" dir="rtl">
<asp:ObjectDataSource ID="ObjDS_AllTasks" runat="server"
SelectMethod="Get_All_Tasks" TypeName="DocumentFlowModuleDTO.TaskDTO">
</asp:ObjectDataSource>
<asp:HiddenField ID="hd_Task_Code" runat="server" />
<table>
<tr>
<td>
<asp:Label ID="Label11" runat="server" Text="Search for Task" Visible="False"></asp:Label>
</td>
<td align="right">
<asp:TextBox ID="txt_Search" runat="server" AutoPostBack="True"
ontextchanged="txt_Search_TextChanged" Width="200px" Visible="False"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="3">
<asp:GridView ID="grd_AllTasks" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CssClass="Alternating" DataKeyNames="task_code"
DataSourceID="ObjDS_AllTasks"
onpageindexchanging="grd_AllTasks_PageIndexChanging"
onrowdatabound="grd_AllTasks_RowDataBound" style="margin-right: 0px">
<RowStyle VerticalAlign="Top" />
HeaderText="ÍÐÝ">
<ItemTemplate>
<asp:ImageButton ID="btn_Delete_Task" runat="server"
CommandArgument="<%# Bind('task_code') %>" Height="33px"
ImageUrl="~/Images/delete.png" oncommand="btn_Delete_Task_Command"
Width="67px" />
<cc1:ConfirmButtonExtender ID="btn_Delete_Task_ConfirmButtonExtender"
runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ æËíÞÉ ÇáÇÚÊãÇÏ ¿" Enabled="True"
TargetControlID="btn_Delete_Task">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="Right" />
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" dir="rtl">
<asp:Label ID="lbl_TaskName" runat="server" Font-Bold="True" Font-Size="13pt"></asp:Label>
</td>
</tr>
<tr>
<td align="center" dir="rtl" style="height: 196px">
<table>
<tr>
<td align="left">
<asp:Label ID="lbl_No_States" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
</td>
<td align="right">
<asp:ImageButton ID="btn_AddStatesToTask" runat="server"
ImageUrl="Images/add.png" onclick="btn_AddStatesToTask_Click" Visible="False" />
<asp:Button ID="Dummy_btn2" runat="server" Text="Button" Style="display:none;" />
<cc1:ModalPopupExtender ID="btn_AddStatesToTask_ModalPopupExtender"
runat="server"
TargetControlID="Dummy_btn2"
BackgroundCssClass="modalBackground"
PopupControlID="pnl_Add_States"
DropShadow="True">
</cc1:ModalPopupExtender>
</td>
</tr>
</table>
<asp:HiddenField ID="hd_StateSerial" runat="server" />
<asp:HiddenField ID="hd_StateRowIndex" runat="server" />
<asp:GridView ID="grd_States" runat="server" AllowPaging="True" DataKeyNames="state_serial"
onpageindexchanging="grd_States_PageIndexChanging" Visible="False"
CssClass="Alternating" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="state_name" HeaderText="ÇáãÑÍáÉ"
ShowHeader="False" />
<asp:BoundField DataField="state_order" HeaderText="ÊÑÊíÈ ÇáãÑÍáÉ"
ShowHeader="False" />
<asp:TemplateField HeaderText="Power" ShowHeader="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chb_StatePower" runat="server"
Checked='<%# Convert.ToBoolean(Eval("power_flag")) %>' Enabled="False" />
</ItemTemplate>
<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="New" ShowHeader="False">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" />
<asp:Button ID="Dummy_btn4" runat="server" Text="Button" Style="display:none;" />
<cc1:ModalPopupExtender ID="btn_TaskState_Edit_ModalPopupExtender" runat="server"
TargetControlID="Dummy_btn4"
BackgroundCssClass="modalBackground"
PopupControlID="pnl_Add_States"
DropShadow="True">
</cc1:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ÍÐÝ" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="btn_TaskState_Delete" runat="server"
CommandArgument="<%# Bind('state_serial') %>" Height="26px"
ImageUrl="~/Images/delete.png" oncommand="btn_TaskState_Delete_Command"
Width="47px" />
<cc1:ConfirmButtonExtender ID="btn_TaskState_Delete_ConfirmButtonExtender"
runat="server" ConfirmText="åá ÊÑíÏ ÍÐÝ ÇáãÑÍáÉ ¿" Enabled="True"
TargetControlID="btn_TaskState_Delete">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td>
<asp:ObjectDataSource ID="ObjectDataSource_States" runat="server"
SelectMethod="Select_TaskStates" TypeName="DocumentFlowModule.DTO.TaskStateDTO">
<SelectParameters>
<asp:Parameter Name="task_code" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnl_Add_Task" runat="server" CssClass="modalPopup"><%-- Style="display:none;"--%>
<div id="div3" style="width: 95%">
<div id="div4" align="center">
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpPnl1" runat="server">
<ContentTemplate>
<table dir="rtl" style="text-align: right">
<tr bgcolor="#f1ece2">
<th align="right" height="35" valign="middle" colspan="3">
<asp:Label ID="lbl_New_Task" runat="server" Font-Bold="False" Font-Size="14pt"
Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
<asp:Label ID="lbl_Edit_Task" runat="server" Font-Bold="False" Font-Size="14pt"
Text="ÊÚÏíá æËíÞÉ ÇÚÊãÇÏ" Visible="False"></asp:Label>
</th>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label1" runat="server" Text="Task Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:TextBox ID="txt_TaskName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_TaskName" ErrorMessage="*" ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label10" runat="server" Text="DataBase Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_DataBases" runat="server" AutoPostBack="True"
ondatabound="ddl_DataBases_DataBound"
onselectedindexchanged="ddl_DataBases_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="ddl_DataBases" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label2" runat="server" Text="Table Name"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_Tables" runat="server" AutoPostBack="True"
ondatabound="ddl_Tables_DataBound"
onselectedindexchanged="ddl_Tables_SelectedIndexChanged">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="ddl_Tables" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label17" runat="server" Text="Table Key"></asp:Label>
</td>
<td style="width: 140px">
<asp:Label ID="lbl_Key" runat="server"></asp:Label>
<asp:CheckBoxList ID="cbl_Columns" runat="server">
</asp:CheckBoxList>
</td>
<td>
<asp:Label ID="lbl_Select_Key" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label18" runat="server" Text="Current Record State"></asp:Label>
</td>
<td style="width: 140px">
<asp:DropDownList ID="ddl_Columns" runat="server" AutoPostBack="True"
ondatabound="ddl_Columns_DataBound">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="ddl_Columns" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label5" runat="server" Text="Form View "></asp:Label>
</td>
<td style="width: 140px">
<asp:TextBox ID="txt_F_View" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txt_F_View" ErrorMessage="*" InitialValue="--Select--"
ValidationGroup="G1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="title" width="160">
<asp:Label ID="Label6" runat="server" Text="Form New"></asp:Label>
</td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td dir="rtl" align="center">
<asp:ImageButton ID="btn_OK" runat="server" ImageUrl="~/Images/add.png"
onclick="btn_OK_Click" ValidationGroup="G1" Visible="False" />
<asp:ImageButton ID="btn_Edit" runat="server" ImageUrl="~/Images/edit.png"
onclick="btn_Edit_Click" ValidationGroup="G1" Visible="False" />
<asp:ImageButton ID="btn_Cancel_Task" runat="server" CausesValidation="False"
Height="36px" ImageUrl="~/Images/cancel.png" onclick="btn_Cancel_Task_Click" />
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
the btn_add _task does not make my popup appear just freeze the parent page
my .cs
protected void btn_Add_Task_Click(object sender, EventArgs e)
{
//AjaxControlToolkit.ModalPopupExtender modal1 = (AjaxControlToolkit.ModalPopupExtender) table1.FindControl("btn_Add_Task_ModalPopupExtender");
//modal1.Show();
grd_States.Visible = false;
lbl_No_States.Text = "";
btn_AddStatesToTask.Visible = false;
lbl_TaskName.Text = "";
//master_editMode.Visible = true;
//pnl_Add_Task.Visible = true;
btn_OK.Visible = true;
btn_Edit.Visible = false;
lbl_New_Task.Visible = true;
lbl_Edit_Task.Visible = false;
txt_TaskName.Text = "";
ddl_DataBases.ClearSelection();
ddl_Tables.Items.Clear();
ddl_Columns.Items.Clear();
cbl_Columns.Items.Clear();
txt_F_New.Text = "";
txt_F_View.Text = "";
txt_Params.Text = "";
txt_SP_Name.Text = "";
btn_Add_Task_ModalPopupExtender.Show();
}
thanks in advance
EDITED::
<table align="center" dir="rtl">
<tr>
<td >
<asp:Button ID="Dummy_btn" runat="server" Text="Button" Style="display:none;" />
<asp:Button ID="btn_Add_Task" runat="server" Text="ÅÖÇÝÉ æËíÞÉ ÇÚÊãÇÏ ÌÏíÏÉ"
onclick="btn_Add_Task_Click" Font-Bold="True" Font-Size="12pt"
ForeColor="#0066FF" />
<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server"
TargetControlID="Dummy_btn"
PopupControlID="pnl_Add_Task"
BackgroundCssClass="modalBackground"
DropShadow="True" >
</cc1:ModalPopupExtender>
</td>
</tr>
</table>`
If you want your modal popup to be displayed when the user clicks on the btn_Add_Task button, you should set that button as the TargetControlID of the extender:
<cc1:ModalPopupExtender ID="btn_Add_Task_ModalPopupExtender" runat="server"
TargetControlID="btn_Add_Task" PopupControlID="pnl_Add_Task"
BackgroundCssClass="modalBackground" DropShadow="True" />
In your current code, the modal popup is triggered by a button named Dummy_btn, which I can't find in your markup, but which probably isn't what you want.
We had many issues with ajax popup. you might want to try the approach we have been using for past one month or so with out any issues. This approach creates a popup with out need of ajax / jquery / javascript /css/ update panel .
here:
A modal popup with out using ajax, update panel, jquery or javascript- surprisingly this seems to work

Categories

Resources