i am using a popup control extender.but i am getting only index of selected value from radiobutton list.I want to get the text
Below is my source code
<div class="FloatRight">
<asp:TextBox ID="txtTeam" runat="server" Width="150px" autocomplete="off"></asp:TextBox>
<br />
<asp:Panel ID="panel" runat="server">
<div style="border: 1px outset white; width: 100px">
<asp:UpdatePanel runat="server" ID="up1">
<ContentTemplate>
<asp:RadioButtonList ID="rbteam" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rbteam_SelectedIndexChanged">
</asp:RadioButtonList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Panel>
<cc1:PopupControlExtender ID="txtTeam_PopupControlExtender" runat="server" Enabled="True"
and this is server side
protected void rbteam_SelectedIndexChanged(object sender, EventArgs e) {
if (!string.IsNullOrEmpty(rbteam.SelectedValue))
{
txtTeam_PopupControlExtender.Commit(rbteam.SelectedValue);
}
else
{
txtTeam_PopupControlExtender.Cancel();
}
rbteam.ClearSelection();
}
txtTeam_PopupControlExtender.Commit(rbteam.SelectedItem.Text);
Related
I am new to ASP.NET and I'm trying to get a Label to update with some information that is grabbed when I hit On selected index changed. The On selected index changed function is called and returns just fine (I've debugged and stepped through the whole thing). The only thing that doesn't work is where I set the text of the Labels I'm trying to update.
This is the function that gets called on the On selected index changed click:
protected void OnClosetIndexChanged(object sender, EventArgs e)
{
{
UpdatePanel updatePanel1 = Row.FindControl("UpdatePanel1") as UpdatePanel;
Label oldSourceQuantity = (Label)Row.FindControl("lblQuantity");
oldSourceQuantity.Text = "0";//Trying to force a value
updatePanel1.Update();
}
}
I know it goes into the if and tries to set the text but nothing happens on the client side.
This is the UpdatePanel I have:
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%" style="background:#F5F5F5" >
<div id="div<%# Eval("componente_id") %>" style="overflow:auto; display:none; position: relative; left: 15px; overflow: auto">
<div class="ExpandTableHeader">
Cambiar la cantidad
</div>
<div class="body">
<label for="validationOfTypeID">Armario:</label>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:DropDownList ID="drCloset" AppendDataBoundItems="True" runat="server" Width="20%" Height="30px" AutoPostBack="true" OnSelectedIndexChanged = "OnClosetIndexChanged"></asp:DropDownList>
<br/>
<label for="validationOfTypeID" visible="false" >cajon</label> <br/>
<asp:DropDownList ID = "drDrawer" AutoPostBack="true" runat="server" Width="20%" Height="30px" >
</asp:DropDownList>
<asp:Label ID="lblQuantity" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostbackTrigger ControlID="drCloset" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<label for="validationOfTypeID"></label>
<asp:DropDownList Height="30px" ID="drOperation" runat="server" >
<asp:ListItem>+</asp:ListItem>
<asp:ListItem>-</asp:ListItem>
</asp:DropDownList>
<asp:TextBox width="50px" ID="txtChangeQuantity" runat="server" TextMode="Number" min="0" step="1" Value="0" ></asp:TextBox>
<asp:Label ID="lblTotal" runat="server" Text=""></asp:Label>
<br/>
</br>
<asp:Button class="btn btn-primary" ID="btnConfirmPurchases" runat="server" Text="Validar" AutoPostback="true" width="20%" />
</div>
<asp:DetailsView id="DetailsView1" DataKeyNames="componente_id" Runat="server" Width="300px" Font-Names="Calibri"/>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
I have a aspx is like shown below
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<asp:UpdatePanel runat="server" ID="panel">
<ContentTemplate>
<asp:Button runat="server" id="bt" text="partial postback" OnClick="E" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" text="full postback" OnClick="J" />
<asp:UpdateProgress runat="server" ID="progress" DynamicLayout="true" AssociatedUpdatePanelID="panel">
<ProgressTemplate>
<div class="divWaiting">
<asp:Label ID="lbl" runat="server" Text="OK" />
<asp:Image ID="imgWait" runat="server" ImageAlign="Middle" ImageUrl="images/indicator.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
On Code Behind I have a function to update my label after making the thread sleep for 3 seconds
public void E(Object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label lbl = (Label)progress.FindControl("lbl");
if (lbl.ToString()!= null)
{
lbl.Text = "SomeThing";
}
update = true;
}
I have two radio buttons with the same groupname. On selection of the one radio button i want two new radio buttons,and on selection of other radio button i want two other new radio button to be visible.
I want all of these inside the ModalPopupExtender.
Here's an example:
ASPX:
<head runat="server">
<title>Modal Popup</title>
<style type="text/css">
.modalStyle
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
.panelStyle
{
width: 300px;
height: 180px;
border: 2px solid Gray;
background-color:White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="scripManager" runat="server" />
<asp:ModalPopupExtender ID="modal" CancelControlID="btnCancel" BackgroundCssClass="modalStyle" PopupControlID="popup" TargetControlID="lblPopup" runat="server" />
<asp:Label ID="lblPopup" runat="server" />
<asp:Panel runat="server" ID="popup" CssClass="panelStyle">
<table style="width: 100%;">
<tr>
<td>
<asp:RadioButton ID="rdboption1" AutoPostBack="true" OnCheckedChanged="CheckedChanged" runat="server" Text="Option 1" GroupName="Options" /><br />
<asp:RadioButton ID="rdboption11" runat="server" Text="Option 1.1" GroupName="SubOption1"
Visible="false" /><br />
<asp:RadioButton ID="rdboption12" runat="server" Text="Option 1.2" GroupName="SubOption1"
Visible="false" />
</td>
</tr>
<tr>
<td>
<asp:RadioButton ID="rdboption2" AutoPostBack="true" OnCheckedChanged="CheckedChanged" runat="server" Text="Option 2" GroupName="Options" /><br />
<asp:RadioButton ID="rdboption21" runat="server" Text="Option 2.1" GroupName="SubOption2"
Visible="false" /><br />
<asp:RadioButton ID="rdboption22" runat="server" Text="Option 2.2" GroupName="SubOption2"
Visible="false" />
</td>
</tr>
<tr>
<td style="text-align: center;">
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</form>
</body>
Code behind:
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
modal.Show();
}
protected void CheckedChanged(object sender, EventArgs e)
{
var radioButton = sender as RadioButton;
ResetOptions();
switch(radioButton.ID)
{
case "rdboption1":
rdboption11.Visible = true;
rdboption12.Visible = true;
break;
case "rdboption2":
rdboption21.Visible = true;
rdboption22.Visible = true;
break;
}
}
private void ResetOptions()
{
rdboption11.Visible = false;
rdboption12.Visible = false;
rdboption21.Visible = false;
rdboption22.Visible = false;
}
}
I'm having Create User Wizard inside an update panel and here is how I have done:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
DisableCreatedUser="True"
ContinueDestinationPageUrl="~/Login.aspx" MailDefinition-BodyFileName="~/EmailTemplates/NewAccountTemplate.htm" LoginCreatedUser="False">
<ContinueButtonStyle BorderStyle="None" CssClass="bar g-button g-button-submit" Font-Size="12px" />
<CreateUserButtonStyle CssClass="foo g-button g-button-red" Height="30px"
Width="125px" BorderStyle="None" Font-Size="12px" />
<MailDefinition BodyFileName="~/EmailTemplates/NewAccountTemplate.htm" From="no-reply#mihirauniverse.org" IsBodyHtml="True" Priority="High">
</MailDefinition>
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<table>
========//Some code here
<tr>
<td>
<asp:Label ID="confirmmsg" runat="server" Text=""></asp:Label>
</td>
</table>
<asp:UpdateProgress ID="UpdateProgressUserDetails" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div style="position: absolute; top: 384px; left: 169px;">
<img src="Main/images/Loader.gif" alt="loading" /><br />
<span style="font-weight: normal; font-size: small; color: #000000;">Please wait...</span>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</ContentTemplate>
</asp:UpdatePanel>
Now I would like to know in which event and how do I display label "confirmmsg" after user account created from codebehind.
use OnCreatedUser "Occurs after the membership provider has created the new Web site user account."
code sample
<asp:CreateUserWizard runat="server" OnCreatedUser="CreateUserWizard1_CreatedUser">
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
// Display the confirm msg
}
I found the answer:
This is what I need to do in the CreatedUser event:
Dim lbl As Label
lbl = CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("confirmmsg")
lbl.Text = "Some text"
Am using a modal pop for a grid view column where the grid view is set with timer.
<asp:UpdatePanel ID="GridPanel" runat="server">
<ContentTemplate>
<asp:Timer ID="autorefresh" runat="server" Interval="5000" />
<asp:GridView ID="SigmaGrid" runat="server" AutoGenerateColumns="False"
onrowcommand="SigmaGrid_RowCommand" CssClass="mGrid" PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" AllowPaging="True"
onpageindexchanging="SigmaGrid_PageIndexChanging">
<AlternatingRowStyle CssClass="alt" />
<PagerStyle />
<Columns>
<asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
<ItemTemplate>
<asp:LinkButton ID="FirstName" runat="server" Text='<% # Eval("FirstName") %>' CommandName="Select"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr" />
</asp:GridView>
<asp:Panel ID="DtlsPanel" runat="server" BackColor="White" Height="400" Width="500px" >
<table style="border: Solid 3px #626262; width: 100%; height: 100%"
cellpadding="0" cellspacing="0">
<tr style="background-color: #626262">
<td colspan="2" style="height: 10%; color: White; font-weight: bold; font-size: larger"
align="center">
Records
</td>
</tr>
<tr>
<td style="color: Black">
First Name:
</td>
<td align="center" style="color: Black">
<asp:Label ID="FNamelbl2" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<asp:Button ID="btnPopUp" runat="server" Style="display: none" />
<asp:ModalPopupExtender ID="DetailsPopUp1" runat="server" BackgroundCssClass="modalBackground"
TargetControlID="btnPopUp" PopupControlID="DtlsPanel" CancelControlID="btnCancel"
PopupDragHandleControlID="PopupHeader">
</asp:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
Code
protected void SigmaGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
LinkButton FirstName = (LinkButton)e.CommandSource;
GridViewRow row = (GridViewRow)FirstName.NamingContainer;
FNamelbl2.Text = FirstName.Text;
this.DetailsPopUp1.Show();
}
}
Problem
Whne i click on firstname colunn i get a pop up which displays the details of a row.. As i have used timer gridview is refreshed and pop up is automatically closing.
If you're using a ModalPopupExtender with postbacks, you should ensure in codebehind that the popup will be shown. Therefore you can use it's method Show.
For example in the page's or UserControl's PreRender:
C#
protected void Page_PreRender(object sender, System.EventArgs e)
{
if (this.Visible) {
this.DetailsPopUp1.Show();
}
}
VB.NET
Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
If Me.Visible Then
Me.DetailsPopUp1.Show()
End If
End Sub