Listbox without values - asp.net

this is what happens. i don't understand why its not working, because if i copy the code to a normal template everything works fine :S so i dont think its a code issue. im working with asp and c#![enter image description here][1]
http://s21.postimg.org/3jsi8351z/weird.png here is a prints screen i took to explain the issue
Asp:
<asp:panel ID="pnltopico" runat="server" GroupingText="Topico" Height="100px"
Width="550px" Visible="False" Wrap="False">
<asp:DropDownList ID="droptopico" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="nome" DataValueField="Id_topico"
Height="22px"
onselectedindexchanged="DroptopicoSelectedIndexCha nged" Width="169px">
</asp:DropDownList>
<asp:panel ID="pnlpermissoestopico" runat="server" GroupingText="Permissões"
Height="59px" style="margin-top: 0px" Width="354px" Wrap="False"
ClientIDMode="inherit">
<asp:ListBox ID="lbpermitidotp" runat="server"
EnableViewState="true" Height="80px"
></asp:ListBox>
<asp:Button ID="btnproibirtp" runat="server" onclick="BtnpermitirClick"
Text=">>" />
<asp:Button ID="btnpermitirtp" runat="server" onclick="BtnnaopermitirClick"
Text="<<" Height="26px" />
<asp:ListBox ID="lbproibidotp" runat="server"
EnableTheming="False" EnableViewState="true" Height="80px" onselectedindexchanged="lbproibidotp_SelectedIndex Changed"
></asp:ListBox> </asp:panel>
since the code is working fine i dont think i need to post the c# code but let me know if it could help.
thanks for your help

Hey I just Modified your code a little and Compiled it everything is working fine now:
<asp:panel ID="pnltopico" runat="server" GroupingText="Topico" Height="100px"
Width="550px" Visible="False" Wrap="False">
<asp:DropDownList ID="droptopico" runat="server" AutoPostBack="True"
DataTextField="nome" DataValueField="Id_topico"
Height="22px"
onselectedindexchanged="droptopico_SelectedIndexChanged" Width="169px">
</asp:DropDownList>
</asp:panel>
<asp:panel ID="pnlpermissoestopico" runat="server" GroupingText="Permissões"
Height="59px" style="margin-top: 0px" Width="354px" Wrap="False"
ClientIDMode="inherit">
<asp:ListBox ID="lbpermitidotp" runat="server"
EnableViewState="true" Height="80px"
>
<asp:ListItem Text="Admin" Value="Admin" />
<asp:ListItem Text="Guest" Value="Guest" />
</asp:ListBox>
<asp:Button ID="btnproibirtp" runat="server" OnClick="btnproibirtp_Click"
Text=">>" />
<asp:Button ID="btnpermitirtp" runat="server"
Text="<<" Height="26px" />
<asp:ListBox ID="lbproibidotp" runat="server" EnableTheming="False" EnableViewState="true" Height="80px">
<asp:ListItem Text="Moderator" Value="Moderator" />
<asp:ListItem Text="Utilizer" Value="Utilizer" />
</asp:ListBox> </asp:panel>
and I have put the breakpoint on the Button Click of the btnproibirtp , just to verify and it works normally ,
I think u had some tags formation error or so :
protected void btnproibirtp_Click(object sender, EventArgs e)
{
string lbl1 = lbproibidotp.SelectedValue;
}
regards

Related

AJAX UpdateProgress does not show

I have an update panel that includes a gridview with two buttons and a modal popup. When the user clicks btnView, the modal popup appears displaying the relevant information.
My issue is that I have been trying to get the updateprogress to appear during the partial postback and so far have not managed it. I should mention that the same UpdateProgress code does work in a test page that just comprises of a button with a sleep function in the code behind. Here is the html:
<!-- Placing the GridView in UpdatePanel-->
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gv" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" DataKeyNames="GroupID" GridLines="Both"
BorderWidth="1px" CellPadding="2" ForeColor="Black" OnRowDataBound="gv_RowDataBound" BorderStyle="Double" HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center" AllowSorting="True" CssClass="gvformat">
<AlternatingRowStyle BackColor="#95B9B9" />
<HeaderStyle BorderStyle="Double" BorderColor="Black"/>
<Columns>
<asp:BoundField DataField="FinancialYear" HeaderText="Financial Year" ItemStyle-HorizontalAlign="Center"/>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="btnView" runat="server" Text="view" OnClick="btnComments_Click" CausesValidation="false" Font-Names="Trebuchet MS" CssClass="btn btn-info" Font-Bold="True" />
</ItemTemplate>
<HeaderTemplate>Comment</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">
<ItemTemplate>
<asp:Button ID="btnDetail" runat="server" Text="view" OnClick="btnDetails_Click" CausesValidation="false" Font-Names="Trebuchet MS" CssClass="btn btn-comment" ForeColor="White" Font-Bold="True" />
</ItemTemplate>
<HeaderTemplate>Details</HeaderTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="bttnHidden" runat="Server" Style="display: none" />
<br />
<asp:Panel ID="pnlComment" runat="server" Width="650px" Height="620px" Style="display: none;" CssClass="modalBox">
<table border="1" class="commentTable" style="border-collapse: separate; border-spacing: 10px; width:100%; height:100%">
<tr><th><asp:Label ID="lblComments" runat="server" Text="Comments" Font-Size="Medium"></asp:Label></th></tr>
<tr><td>
<asp:TextBox ID="txtExistingComments" runat="server" TextMode="MultiLine" ReadOnly="True" CssClass="content" Rows="12" Font-Names="Trebuchet MS"></asp:TextBox>
</td></tr>
<tr><th><asp:Label ID="lblNewComment" runat="server" Text="Add Comment" Font-Size="Medium"></asp:Label></th></tr>
<tr><td>
<asp:TextBox ID="txtNewComments" runat="server" TextMode="MultiLine" ReadOnly="False" CssClass="content" Rows="12" Font-Names="Trebuchet MS"></asp:TextBox></td></tr>
<tr><td>
<asp:Button ID="btnSave" runat="server" width="100px" Text="Save" OnClick="btnSave_Click" CssClass="btn btn-comment" ValidationGroup="SaveComment" ForeColor="White" Font-Bold="True" />
<asp:Button ID="btnCancel" runat="server" width="100px" Text="Cancel" CssClass="btn btn-comment" ForeColor="White" Font-Bold="True"/></td></tr>
<tr>
<td>
<asp:RequiredFieldValidator ID="rfValidator" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtNewComments"
ForeColor="Black" ValidationGroup="SaveComment" Font-Bold="True">You must enter a comment!</asp:RequiredFieldValidator>
</td>
</tr>
</table>
</asp:Panel>
<cc1:ModalPopupExtender ID="modal" runat="server" TargetControlID="bttnHidden" PopupControlID="pnlComment" CancelControlID="btnCancel" BackgroundCssClass="modalBackground"></cc1:ModalPopupExtender>
<br />
<asp:HiddenField ID="Hidden" runat="server" value="-1"/>
<asp:HiddenField ID="bStatus" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" ChildrenAsTriggers="false" UpdateMode="Conditional" DisplayAfter="10">
<ProgressTemplate>
<div class="center">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/Images/loader.gif" AlternateText="Please wait ..." ToolTip="Please wait ..." />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>
Any help would be most appreciated!
two points you need to check.
First if you have any javascript errors - this Update Progress is base on javascrip, so any javascript error can stop the function of it. Open the console panel and check for javascript errors...
The second point is to check the DisplayAfter property on UpdateProgress, that is 500 milliseconds default value. If anything happens within this time, the UpdateProgress is not show. So add a lower value on DisplayAfter to check it out.

asp:RadioButtonList asp:RequiredFieldValidator Never fires the validation

I have a webforms page (don't ask) that I am trying to get some client side validation working on, using the standard validators.
Heres some partial code
<asp:TemplateField ItemStyle-Width="50px" HeaderText="Received">
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:RadioButtonList ID="rbIsRecv" RepeatDirection="Horizontal"
runat="server" ValidationGroup="Curriculum">
<asp:ListItem Value="1">Yes </asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1"
ControlToValidate="rbIsRecv" Text="Required"
ValidationGroup="Curriculum" />
</ItemTemplate>
</asp:TemplateField>
<.......>
<asp:TemplateField ItemStyle-Width="50px" HeaderText="Actually Received">
<HeaderStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:TextBox ID="txtActual" runat="server" />
<asp:RequiredFieldValidator ForeColor="Red" ValidationGroup="AllValidators" runat="server"
ControlToValidate="txtActual" ErrorMessage="All values must be filled in!" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</div>
</div>
<div class="row pull-right">
<asp:Label runat="server">Employee ID: </asp:Label>
<asp:TextBox ID="txtName" runat="server" /><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" CssClass="btn-primary pull-right" />
</div>
<div class="row">
<asp:RequiredFieldValidator ForeColor="Red" ValidationGroup="AllValidators" runat="server" ControlToValidate="txtName" ErrorMessage="Please enter your employee Number!" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="AllValidators"/>
</div>
So when I submit it throws and error to the Summary Control from the txtName control properly, but none of the controls within the grids....
Any ideas?
You cannot validate a RadioButtonList with a RequiredFieldValidator. You need a CustomValidator for that.
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Select an option"
ClientValidationFunction="validateRadioButtonList"></asp:CustomValidator>
<script type="text/javascript">
function validateRadioButtonList(oSrc, args) {
if ($("input[name='<%= RadioButtonList1.UniqueID %>']:checked").val() == null) {
args.IsValid = false;
} else {
args.IsValid = true;
}
}
</script>

modal popup not showing from code behind

<asp:UpdatePanel ID="updtpnlacademic" runat="server">
<ContentTemplate>
<td>
<asp:GridView ID="gdvwAcademic1" runat="server" OnRowCommand="gdvwAcademic1_RowCommand" OnRowDeleting="gdvwAcademic1_RowDeleting" CellPadding="4" ForeColor="#333333" GridLines="None" Width="100%" AllowSorting="True" AutoGenerateColumns="False" HorizontalAlign="Center">
<Columns>
....Other column fields
<asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center" ShowHeader="false">
<ItemTemplate>
<asp:ImageButton ID="imgbtnacademicdelete" CommandName="Delete" OnClick="imgbtnacademicdelete_Click" CommandArgument='<%# ((GridViewRow)Container).RowIndex %>' ToolTip="Delete" runat="server" ImageAlign="Top" ImageUrl="~/Images/delete.png" Width="30" Height="25"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btndummy" runat="server" Visible="false" />
<cc1:ModalPopupExtender ID="mpacademic" runat="server" TargetControlID="btndummy" PopupControlID="Panel2" CancelControlID="btnacademicClose" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel2" runat="server" CssClass="modalPopup" HorizontalAlign="Center" style = "display:none">
<span style="color:white; font-family:'Bookman Old Style'; font-weight:bold;">Really Want To Delete This Record...!</span><br /><br /><br /><br />
<asp:Button ID="btnconfirmacademicdelete" OnClick="btnconfirmacademicdelete_Click" CssClass="BStyle" Font-Bold="true" runat="server" Text="Yes" />
<asp:Button ID="btnacademicClose" Font-Bold="true" runat="server" CssClass="BStyle" Text="Cancel" />
</asp:Panel>
</td>
</ContentTemplate>
</asp:UpdatePanel>
And following code as in the code behind ....
protected void gdvwAcademic1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
mpacademic.Show();
//System.Windows.Forms.MessageBox.Show("RowDeleting clicked after this modal popup should be displayed.....!");
}
It only show messagebox on event if uncomment messagebox but not showing modal popup
<cc1:ModalPopupExtender ID="mpacademic" runat="server" TargetControlID="btndummy" PopupControlID="Panel2" CancelControlID="btnacademicClose" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
The TargetControlID property is set to btndummy and
<asp:Button ID="btndummy" runat="server" Visible="false" />
btndummy is not rendering since Visible property is set to false.
Try to replace
<asp:Button ID="btndummy" runat="server" Visible="false" />
With
<asp:Button ID="btndummy" runat="server" style="display:none" />

Ajax for asp.net form view

Inside form view I have drop down list on selected index change I have text box appearing.
Now I want to keep both these drop down and Text box inside Ajax update panel. Upon click button out side update panel I want to save these two fields as well.
Any help Much appreciated.
Here aspx code
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:DropDownList ID="ddlLName"
runat="server" ValidationGroup="VG1" SelectedValue='<%# Bind("LNAMEIFYES") %>' OnSelectedIndexChanged="ddlLName_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="">Please select...</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="2">No</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Panel ID="pnlLNAme" runat="server" Visible="false">
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
</asp:Panel>
Code Behind
protected void ddlLName_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlLName = (DropDownList)FormView1.FindControl("ddlLName");
if (ddlLName.SelectedValue == "1")
{
Panel pnlLNAme = (Panel)FormView1.FindControl("pnlLNAme");
pnlLNAme.Visible = true;
}
else
{
Panel pnlLNAme = (Panel)FormView1.FindControl("pnlLNAme");
pnlLNAme.Visible = false;
}
}
I solved the problem by using by using two update panals, using trigger in one of the update panal.
<EditItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
ID:
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:DropDownList ID="ddlLName"
runat="server" ValidationGroup="VG1" SelectedValue='<%# Bind("LNAMEIFYES") %>' OnSelectedIndexChanged="ddlLName_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="">Please select...</asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="2">No</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Panel ID="pnlLNAme" runat="server" Visible="false">
LName:
<asp:TextBox ID="LNameTextBox" runat="server" Text='<%# Bind("LName") %>' />
<br />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
Salary:
<asp:TextBox ID="SalaryTextBox" runat="server" Text='<%# Bind("Salary") %>' />
<br />
IsActive:
<asp:CheckBox ID="IsActiveCheckBox" runat="server" Checked='<%# Bind("IsActive") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateButton" EventName="Click_Enent" />
</Triggers>
</asp:UpdatePanel>
</EditItemTemplate>

asp.net ModalPopupExtender not behaving properly

I have the following code on a .aspx file. If I comment out the ModalPopupExtender code works fine.:
<cc1:ModalPopupExtender BehaviorID="mdlPopup" runat="server" TargetControlID="btn"
ID="mdl1" PopupControlID="pnlPopup" OkControlID="LinkButton1" BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlPopup" runat="server" CssClass="confirm-dialog" Style="display: none;">
<div class="inner">
Work Order #: <asp:TextBox ID="txtWorkOrder" runat="server" Width="285" Text=""></asp:TextBox><br /><br />
Please Enter Corrective Actions<br />
<asp:TextBox ID="TextBox2" runat="server" Height="150" Width="285" TextMode="MultiLine"
Text=""></asp:TextBox>
<asp:Button ID="btnOK" runat="server" Font-Bold="true" Text="Submit" OnClick="click"
Width="150" />
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="close" OnClick="cancel" />
</div>
</asp:Panel>
<asp:Button ID="btn" runat="server" Style="display: none;" />
<asp:Label ID="id" runat="server" Text="Label" Visible="false"></asp:Label>
The problem that I am having is that the page just hangs when I have this code in the .aspx file. Is there anything I should do. It does not even get to the Page_Load.
I am calling this page that has the above code with the following:
string url = "Alerts.aspx?";
url += "ID=" + id.Text;
Response.Redirect(url);

Resources