update panel is not working on asp.net code - c#

This is my c# code behind
protected void callDispositionChanged(object sender, EventArgs e)
{
var dropDown = (DropDownList)ListView1.FindControl("callDispositionSelector");
var visitID = (TextBox)ListView1.FindControl("visitID");
if (dropDown != null)
{
Response.Write(dropDown.SelectedValue + "ssssssssss");
visitID.Text = dropDown.SelectedValue;
}
else
{
visitID.Text = "ffffff";
Response.Write("FFFFFFFFFFFFFFFF");
}
}
this is my asp code
<asp:UpdatePanel ID="UpdatePanel3" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<tr class="footer" runat="server">
<td colspan="4" runat="server">* By VoiceMpower
<asp:DropDownList AutoPostBack="true" runat="server" ID="callDispositionSelector" OnSelectedIndexChanged="callDispositionChanged" clientidmode="Static">
<asp:ListItem Value="-1">Select Disposition Reason</asp:ListItem>
<asp:ListItem Value="1">Reservation</asp:ListItem>
<asp:ListItem Value="2">Change of Reservation</asp:ListItem>
<asp:ListItem Value="3">Cancellation</asp:ListItem>
<asp:ListItem Value="4">Wait List</asp:ListItem>
<asp:ListItem Value="5">Other</asp:ListItem>
</asp:DropDownList>
<asp:TextBox runat="server" ID="visitID" clientidmode="Static"></asp:TextBox>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
when I change the value of the select, the function is executed, but the results (the post back page) has the select in the devaul vaule.
note
i already have
<asp:ScriptManager ID="ScriptManager2" runat="server" />
note 3
that asp code exist in item template in asp.listview
Note2
I can't debug the project because the database on the server and I am not allowed to make a link to it. So each time i develop a functoin, I go and deploy the website on the server and test it. So please let your answers without making break points and something like that. thanks in advance

You are using Conditional Mode which means, the update panel will not work, unless the event is triggered.
Remove that.
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<tr class="footer" runat="server">
<td colspan="4" runat="server">* By VoiceMpower
<asp:DropDownList AutoPostBack="true" runat="server" ID="callDispositionSelector" OnSelectedIndexChanged="callDispositionChanged" ClientIDMode="Static">
<asp:ListItem Value="-1">Select Disposition Reason</asp:ListItem>
<asp:ListItem Value="1">Reservation</asp:ListItem>
<asp:ListItem Value="2">Change of Reservation</asp:ListItem>
<asp:ListItem Value="3">Cancellation</asp:ListItem>
<asp:ListItem Value="4">Wait List</asp:ListItem>
<asp:ListItem Value="5">Other</asp:ListItem>
</asp:DropDownList>
<asp:TextBox runat="server" ID="visitID" ClientIDMode="Static"></asp:TextBox>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>

Related

How to prevent one update panel from affecting another c# asp

My problem is the following, when I first use the droplist of the first updatepanel to function correctly it shows me the label and textbox that are hidden, everything works fine.
But, when I use first the dropProvince, canton or district, they implement the method
protected void
droplistTipoIdentificacionDatosPropietario_SelectedIndexChanged (object sender, EventArgs and )
{
MessageBox.Show ("hello");
this.datosPropietarioLblNumIdentificacion.Visible = true;
this.datosPropietariotxtNumIdentificacion.Visible = true;
}
each drop has its own method
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.datosPropietarioLblNumIdentificacion.Visible = false;
this.datosPropietariotxtNumIdentificacion.Visible = false;
}
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" Text="Tipo de Identificación"></asp:Label>
<asp:DropDownList ID="droplistTipoIdentificacionDatosPropietario"
runat="server"
Width="100%"
Height="30px"
AutoPostBack="true"
OnSelectedIndexChanged="droplistTipoIdentificacionDatosPropietario_SelectedIndexChanged">
<asp:ListItem Text="Cédula Identidad" Value="C"></asp:ListItem>
<asp:ListItem Text="Cédula de Residencia" Value="R"></asp:ListItem>
<asp:ListItem Text="Cédula Jurídica" Value="J"></asp:ListItem>
<asp:ListItem Text="Pasaporte" Value="P"></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
Code Behind call
protected void droplistTipoIdentificacionDatosPropietario_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("hola");
this.datosPropietarioLblNumIdentificacion.Visible = true;
this.datosPropietariotxtNumIdentificacion.Visible = true;
}
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="grid3">
<asp:Label runat="server" Text="Provincia"></asp:Label>
<asp:DropDownList ID="droplistProvincia"
AutoPostBack="true" onchange="testProvincia"
OnSelectedIndexChanged="droplistProvincia_SelectedIndexChanged"
Width="100%" runat="server" Height="30px">
<asp:ListItem Text="Seleccione"></asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" Text="Cantón"></asp:Label>
<asp:DropDownList ID="droplistCanton" CssClass="item15"
AutoPostBack="true"
OnSelectedIndexChanged="droplistCanton_SelectedIndexChanged"
Width="100%" runat="server" Height="30px">
<asp:ListItem Text="Seleccione"></asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" CssClass="item16" Text="Distrito"></asp:Label>
<asp:DropDownList ID="droplistDistrito"
AutoPostBack="true"
OnSelectedIndexChanged="droplistDistrito_SelectedIndexChanged"
CssClass="item17" runat="server" Height="30px">
<asp:ListItem Text="Seleccione"></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
You might have a copy/paste issue; sometimes copy/paste will not execute code. Try deleting the code-behind methods from each dropdown and re-adding them.
<asp:DropDownList ID="droplistProvincia"
AutoPostBack="true" onchange="testProvincia"
OnSelectedIndexChanged="droplistProvincia_SelectedIndexChanged" <- delete this
Width="100%" runat="server" Height="30px">
<asp:ListItem Text="Seleccione"></asp:ListItem>
</asp:DropDownList>
Delete the line as shown above, and also delete the code-behind. Re-add by double-clicking the dropdown list.
Hope that helps. It's hard to tell what the problem is from your question.

RadioButtonList not posting back despite autopostback being set to true

I'm having issues trying to get radio button list selected index changes to fire, and although I have no issues with postbacks on any other asp control, radio button lists are giving me trouble. I'll include my asp code and c# codebehind in the event one of you may be able to discern what's wrong.
I have 8 radio button lists, all within their own update panels that are set to always update, and each radio button list has autopostback set to true.
I have code behind logic changing two asp:labels, one changing the average scores based on the radiobuttonlist selections, and one assigning a risk level depending on the value of the average score.
<table class="td-table-bordered" style="width: 90%">
<tr>
<th>
<asp:Label ID="CategoryLabel" runat="server" Text="Category"></asp:Label>
</th>
<th>
<asp:Label ID="OccurrenceProbabilityLabel" runat="server" Text="Probability of Occurrence"></asp:Label>
</th>
<th>
<asp:Label ID="ProbabilityRatingLabel" runat="server" Text="Rating"></asp:Label><br />
<asp:Label ID="ProbabilityRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
</th>
<th>
<asp:Label ID="OccurrenceImpactLabel" runat="server" Text="Impact of Occurrence"></asp:Label>
</th>
<th>
<asp:Label ID="ImpactRatingLabel" runat="server" Text="Rating"></asp:Label><br />
<asp:Label ID="ImpactRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
</th>
</tr>
<tr>
<td>
<asp:Label ID="BaseDesktopLabel" runat="server" Text="Base Desktop"></asp:Label>
</td>
<td>
<asp:Label ID="BaseDesktopProbabilityLabel" runat="server" Text="Based on workspace/RBB assessment, what is the probability that this change could impact function, performance or availability of a base component?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="DesktopProbabilityPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="DesktopProbabilityButtonList" runat="server" OnSelectedIndexChanged="DesktopProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Label ID="BaseDesktopImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the workstation?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="DesktopImpactPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="DesktopImpactButtonList" runat="server" OnSelectedIndexChanged="DesktopImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="ProductivityLayerLabel" runat="server" Text="Productivity Layer"></asp:Label>
</td>
<td>
<asp:Label ID="ProductivityLayerProbabilityLabel" runat="server" Text="Based on workspace/RBB engineering assessment, what is the probability that this change could impact function, performance or availability of a productivity application?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="ProductivityProbabilityPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="ProductivityProbabilityButtonList" runat="server" OnSelectedIndexChanged="ProductivityProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Label ID="ProductivityLayerImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the productivity application?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="ProductivityImpactPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="ProductivityImpactButtonList" runat="server" OnSelectedIndexChanged="ProductivityImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="BusinessApplicationsLabel" runat="server" Text="Business Applications"></asp:Label>
</td>
<td>
<asp:Label ID="BusinessApplicationsProbabilityLabel" runat="server" Text="Based on workspace engineering assessment, what is the probability that this change could impact function, performance or availability of a business application?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="BusinessProbabilityPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="BusinessProbabilityButtonList" runat="server" OnSelectedIndexChanged="BusinessProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Label ID="BusinessApplicationsImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the business application?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="BusinessImpactPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="BusinessImpactButtonList" runat="server" OnSelectedIndexChanged="BusinessImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td>
<asp:Label ID="DatacenterLabel" runat="server" Text="Datacenter/Infrastructure"></asp:Label>
</td>
<td>
<asp:Label ID="DatacenterProbabilityLabel" runat="server" Text="What is the probability that this change could impact function, performance or availability of networks, infrastructure or web services used by the branch??"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="DatacenterProbabilityPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="DatacenterProbabilityButtonList" runat="server" OnSelectedIndexChanged="DatacenterProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:Label ID="DataCenterImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the datacenter or infrastructure?"></asp:Label>
</td>
<td>
<asp:UpdatePanel ID="DataCenterImpactPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButtonList ID="DatacenterImpactButtonList" runat="server" OnSelectedIndexChanged="DatacenterImpactList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td> </td>
<td style="text-align: right">
<asp:Label ID="OverAllRatingLabel" runat="server" Font-Bold="True" Text="Change Risks Overall Average Rating: "></asp:Label>
</td>
<td style="text-align: right">
<asp:Label ID="OverallRating" runat="server" Font-Bold="True"></asp:Label>
</td>
<td style="text-align: right">
<asp:Label ID="OverallRiskLabel" runat="server" Font-Bold="True" Text="Overall Risk: "></asp:Label>
</td>
<td style="text-align: right">
<asp:Label ID="OverallRisk" runat="server" Font-Bold="True"></asp:Label>
</td>
</tr>
</table>
And now my c#
double averageRating, desktopProbabilityRating, desktopImpactRating, productivityProbabilityRating, productivityImpactRating, businessProbabilityRating, businessImpactRating, datacenterProbabilityRating, datacenterImpactRating = 0;
protected void DesktopProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
desktopProbabilityRating = Convert.ToDouble(DesktopProbabilityButtonList.SelectedValue);
calculateAverage();
}
protected void DesktopImpactButtonList_SelectedIndexChanged(object sender, EventArgs e) {
desktopImpactRating = Convert.ToDouble(DesktopImpactButtonList.SelectedValue);
calculateAverage();
}
protected void ProductivityProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
productivityProbabilityRating = Convert.ToDouble(ProductivityProbabilityButtonList.SelectedValue);
calculateAverage();
}
protected void ProductivityImpactButtonList_SelectedIndexChanged(object sender, EventArgs e) {
productivityImpactRating = Convert.ToDouble(ProductivityImpactButtonList.SelectedValue);
calculateAverage();
}
protected void BusinessProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
businessProbabilityRating = Convert.ToDouble(BusinessProbabilityButtonList.SelectedValue);
calculateAverage();
}
protected void BusinessImpactButtonList_SelectedIndexChanged(object sender, EventArgs e) {
businessImpactRating = Convert.ToDouble(BusinessImpactButtonList.SelectedValue);
calculateAverage();
}
protected void DatacenterProbabilityButtonList_SelectedIndexChanged(object sender, EventArgs e) {
datacenterProbabilityRating = Convert.ToDouble(DatacenterProbabilityButtonList.SelectedValue);
calculateAverage();
}
protected void DatacenterImpactList_SelectedIndexChanged(object sender, EventArgs e) {
datacenterImpactRating = Convert.ToDouble(DatacenterImpactButtonList.SelectedValue);
calculateAverage();
}
protected void calculateAverage() {
averageRating = (desktopProbabilityRating + desktopImpactRating + productivityProbabilityRating + productivityImpactRating + businessProbabilityRating + businessImpactRating + datacenterProbabilityRating + datacenterImpactRating) / 8;
OverallRating.Text = averageRating.ToString();
if(averageRating <= 1) {
OverallRisk.Text = "Low";
}
else if(averageRating > 1 && averageRating < 3) {
OverallRisk.Text = "Med";
}
else if(averageRating >=3 || desktopProbabilityRating == 3 || desktopImpactRating == 3 || productivityProbabilityRating == 3 || productivityImpactRating == 3 || businessProbabilityRating == 3 || businessImpactRating == 3 || datacenterProbabilityRating == 3 || datacenterImpactRating == 3) {
OverallRisk.Text = "High";
}
}
This SHOULD be posting back, I absolutely can't determine why every other control on my form posts back just fine and not these. Would someone be able to help determine why? No other question on stack overflow concerning this applied to my problem.
Thanks so much in advance.
Your labels are outside the update panels, that is why it is not working. All the radio buttons postback without any issue.
I would suggest you to wrap all the controls inside one update panel.
Please read further here https://forums.asp.net/t/1120428.aspx?Update+Label+outside+update+panel
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<table class="td-table-bordered" style="width: 90%">
<tr>
<th>
<asp:Label ID="CategoryLabel" runat="server" Text="Category"></asp:Label>
</th>
<th>
<asp:Label ID="OccurrenceProbabilityLabel" runat="server" Text="Probability of Occurrence"></asp:Label>
</th>
<th>
<asp:Label ID="ProbabilityRatingLabel" runat="server" Text="Rating"></asp:Label><br />
<asp:Label ID="ProbabilityRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
</th>
<th>
<asp:Label ID="OccurrenceImpactLabel" runat="server" Text="Impact of Occurrence"></asp:Label>
</th>
<th>
<asp:Label ID="ImpactRatingLabel" runat="server" Text="Rating"></asp:Label><br />
<asp:Label ID="ImpactRatingLabel2" runat="server" Text="(L/M/H)"></asp:Label>
</th>
</tr>
<tr>
<td>
<asp:Label ID="BaseDesktopLabel" runat="server" Text="Base Desktop"></asp:Label>
</td>
<td>
<asp:Label ID="BaseDesktopProbabilityLabel" runat="server" Text="Based on workspace/RBB assessment, what is the probability that this change could impact function, performance or availability of a base component?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="DesktopProbabilityButtonList" runat="server" OnSelectedIndexChanged="DesktopProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:Label ID="BaseDesktopImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the workstation?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="DesktopImpactButtonList" runat="server" OnSelectedIndexChanged="DesktopImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="ProductivityLayerLabel" runat="server" Text="Productivity Layer"></asp:Label>
</td>
<td>
<asp:Label ID="ProductivityLayerProbabilityLabel" runat="server" Text="Based on workspace/RBB engineering assessment, what is the probability that this change could impact function, performance or availability of a productivity application?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="ProductivityProbabilityButtonList" runat="server" OnSelectedIndexChanged="ProductivityProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:Label ID="ProductivityLayerImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the productivity application?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="ProductivityImpactButtonList" runat="server" OnSelectedIndexChanged="ProductivityImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="BusinessApplicationsLabel" runat="server" Text="Business Applications"></asp:Label>
</td>
<td>
<asp:Label ID="BusinessApplicationsProbabilityLabel" runat="server" Text="Based on workspace engineering assessment, what is the probability that this change could impact function, performance or availability of a business application?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="BusinessProbabilityButtonList" runat="server" OnSelectedIndexChanged="BusinessProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:Label ID="BusinessApplicationsImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the business application?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="BusinessImpactButtonList" runat="server" OnSelectedIndexChanged="BusinessImpactButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="DatacenterLabel" runat="server" Text="Datacenter/Infrastructure"></asp:Label>
</td>
<td>
<asp:Label ID="DatacenterProbabilityLabel" runat="server" Text="What is the probability that this change could impact function, performance or availability of networks, infrastructure or web services used by the branch??"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="DatacenterProbabilityButtonList" runat="server" OnSelectedIndexChanged="DatacenterProbabilityButtonList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:Label ID="DataCenterImpactLabel" runat="server" Text="If a problem did occur, what could be the extent of the impact to the operation of the datacenter or infrastructure?"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="DatacenterImpactButtonList" runat="server" OnSelectedIndexChanged="DatacenterImpactList_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Text="High" Value="3"></asp:ListItem>
<asp:ListItem Text="Med" Value="2"></asp:ListItem>
<asp:ListItem Text="Low" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td> </td>
<td style="text-align: right">
<asp:Label ID="OverAllRatingLabel" runat="server" Font-Bold="True" Text="Change Risks Overall Average Rating: "></asp:Label>
</td>
<td style="text-align: right">
<asp:Label ID="OverallRating" runat="server" Font-Bold="True"></asp:Label>
</td>
<td style="text-align: right">
<asp:Label ID="OverallRiskLabel" runat="server" Font-Bold="True" Text="Overall Risk: "></asp:Label>
</td>
<td style="text-align: right">
<asp:Label ID="OverallRisk" runat="server" Font-Bold="True"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

I used a drop down box to load different text box based on option from drop down box but unable to get default view

I used a drop down box named dd1 to display the list of cards like select card,visa,master cards.when i use select card as default view in dd1, i should not get any text boxes displayed and when visa or master cards are selected it should display text boxes and labels asking name and card number etc. i am able to get the labels and textboxes when selected visa or master but could not get the default view on selection of select card(which is first option in dd1)
this is the code
<asp:DropDownList ID="dd1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dd1_SelectedIndexChanged1">
<asp:ListItem Text="---Select amount" Selected="True" Value="0"></asp:ListItem>
<asp:ListItem Text="Master card" Value="1"></asp:ListItem>
<asp:ListItem Text="Maestro" Value="2"></asp:ListItem>
<asp:ListItem Text="Visa" Value="3"></asp:ListItem>
<asp:ListItem Text="Visa Debit" Value="4"></asp:ListItem>
<asp:ListItem Text="Post office Credit card" Value="5"></asp:ListItem>
</asp:DropDownList>
<asp:MultiView ID="multiview" ActiveViewIndex="-1" runat="server">
<asp:View ID="viewtext" runat="server">
<p>
<asp:Label ID="cardname" runat="server" Text="Name on card"></asp:Label>
<asp:TextBox ID="text1" runat="server" Text=""></asp:TextBox>
</p>
<p>
<asp:Label ID="cardnumber" runat="server" Text="Card number"></asp:Label>
<asp:TextBox ID="text2" runat="server"></asp:TextBox>
</p>
Code behind is as follows:
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
return;
}
protected void dd1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (dd1.SelectedValue=="1")
{
multiview.ActiveViewIndex = 0;
}
}
}
Please help me with this..Thank you in advance..
its working on my side. like below
<asp:DropDownList ID="dd1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dd1_SelectedIndexChanged1">
<asp:ListItem Text="---Select amount" Selected="True" Value="0"></asp:ListItem>
<asp:ListItem Text="Master card" Value="1"></asp:ListItem>
<asp:ListItem Text="Maestro" Value="2"></asp:ListItem>
<asp:ListItem Text="Visa" Value="3"></asp:ListItem>
<asp:ListItem Text="Visa Debit" Value="4"></asp:ListItem>
<asp:ListItem Text="Post office Credit card" Value="5"></asp:ListItem>
</asp:DropDownList>
<asp:MultiView ID="multiview" ActiveViewIndex="0" runat="server">
<asp:View ID="viewtext" runat="server">
<p>
Default View
</p>
</asp:View>
<asp:View ID="view1" runat="server">
<p>
Master card
</p>
</asp:View>
<asp:View ID="view2" runat="server">
<p>
Maestro
</p>
</asp:View>
<asp:View ID="view3" runat="server">
<p>
Visa
</p>
</asp:View>
<asp:View ID="view4" runat="server">
<p>
Visa Debit
</p>
</asp:View>
<asp:View ID="view5" runat="server">
<p>
Post office Credit card
</p>
</asp:View>
</asp:MultiView>
Code
protected void dd1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (dd1.SelectedItem != null)
{
multiview.ActiveViewIndex = Convert.ToInt16(dd1.SelectedValue);
}
}

asp.net drop downlist value reset on button click within jquery dialog

I have a div , within which I have a button and an asp.net dropdownlist. I can change the value in the dropdownlist . But as soon as the button is clicked the value in the drop down list is again set to the default initial value. Is there a way I can solve this problem ? I do not want the dropdownlist to go back to its initial value.
aspx
<div id='one'>
<asp:LinkButton ID="ConfigureAlerts" OnClick="btnConfigureAlerts_Click" runat="server">Configure Alerts</asp:LinkButton>
</div>
<div id="ViewModalPopupDiv2">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" HorizontalAlign="left" ScrollBars="Auto">
<asp:Button ID="btnGetLogs" runat="server" Text="SendAlerts" OnClick="btnSendAlertEmail_Click"/>
<asp:Label ID="Label2" runat="server" Text="Set The Alert Email Interval to every :" CssClass="label"
ForeColor="Black"></asp:Label>&nbsp&nbsp&nbsp
<asp:DropDownList ID="ddlTimeInterval" runat="server" >
<asp:ListItem Text="15MIN" Value="15"></asp:ListItem>
<asp:ListItem Text="30MIN" Value="30"></asp:ListItem>
<asp:ListItem Text="1Hr" Value="60"></asp:ListItem>
<asp:ListItem Text="2Hrs" Value="120"></asp:ListItem>
<asp:ListItem Text="8Hrs" Value="480"></asp:ListItem>
<asp:ListItem Text="24Hrs" Value="1440"></asp:ListItem>
<asp:ListItem Text="48Hrs" Value="2880"></asp:ListItem>
</asp:DropDownList>
<br />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
javascript
function ViewModelPopup2() {
$("#ViewModalPopupDiv2").dialog({
scrollable: true,
width: 800,
modal: true
});
}
ASPX.CS
protected void btnSendAlertEmail_Click(object sender, EventArgs e)
{
// Code to send email
}
protected void btnConfigureAlerts_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript
(this, this.GetType(), "callScriptFunction", "ViewModelPopup2();", true);
}
}
The problem i can see is that , JQuery and Update Panel. These two never works together properly. You need to remove either. But there is a work around. Check out this one.http://www.codeproject.com/Articles/601683/Working-with-jQuery-within-the-ASP-NET-UpdatePanel

How to create new radiobuttonlist with question on submit? c# asp.net

i have:
<div id="question">
<div style="float: left; width: 250px;">
<asp:Label ID="question" runat="server"></asp:Label></div>
<div>
<asp:RadioButtonList ID="selectdYesNo" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
<div id="btCreate" style="margin-left: 200px; margin-top: 10px;">
<asp:Button runat="server" Text="Categorize" ID="btCategorize" />
</div>
how can i create new entry of radiobuttonlist with new question after submit?? im princip create new 2, 3, 4 etc.
here is your code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PanelFirstQuestionBlock.Visible = true;
}
}
protected void FirstQuestionGotAnswered(object sender, EventArgs e)
{
PanelFirstQuestionBlock.Visible = false;
PanelSecondQuestionBlock.Visible = true;
}
here your ASP:HTML
<asp:Panel ID="PanelFirstQuestionBlock" runat="server" Visible="false">
<h1>My first Question</h1>
<asp:RadioButtonList ID="RadioButtonListAnswer1" runat="server"
OnSelectedIndexChanged="FirstQuestionGotAnswered">
<asp:ListItem>yes</asp:ListItem>
<asp:ListItem>no</asp:ListItem>
</asp:RadioButtonList>
</asp:Panel>
<asp:Panel ID="PanelSecondQuestionBlock" runat="server" Visible="false">
<h1>My second Question</h1>
<asp:RadioButtonList ID="RadioButtonListAnswer2" runat="server">
<asp:ListItem>yes</asp:ListItem>
<asp:ListItem>no</asp:ListItem>
</asp:RadioButtonList>
</asp:Panel>
you can try like this selectdYesNo.Items.Add(new ListItem("text","value"));
You should place third entry between:
<%
if (needToShowThirdEntry) {
%>
and
<%
}
%>
So, your code:
<asp:RadioButtonList ID="selectdYesNo" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
<%
if (needToShowThirdEntry) {
%>
<asp:ListItem Text="Maybe" Value="2"></asp:ListItem>
<%
}
%>
</asp:RadioButtonList>
UPDATE
As you updated your question, my new answer would be:
<asp:RadioButtonList ID="selectdYesNo" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
<%
if (needToShowSecondList) {
%>
<asp:RadioButtonList ID="newRBList" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
<asp:ListItem Text="Maybe" Value="2"></asp:ListItem>
</asp:RadioButtonList>
<%
}
%>
But, as this is separate list, you should make normal radio button list (without if) and use newRBList.Visible property from code behind to hide it on first rendering (before postback)

Categories