Update panel with Html code post back - c#

I have html control dropdown with multiselection in Update panel. I want a post back on change or complete the multiselctio dropdown option.
<ContentTemplate>
<table class="boxTable1" style="width: 100%;">
<tr style="height: 5px;">
<td colspan="2"> </td>
</tr>
<tr>
<td>
<asp:Label ID="lblBPSIOU" runat="server" Text="BPS IOU"></asp:Label></td>
<td>
<select id="ddlroll" runat="server" multiple="true" onclick="javascript:__doPostBack(this,'')" class="multiselect-group">
</select>
</td>
<td>
<asp:Label ID="lblName" runat="server" Text="Name"></asp:Label></td>
<td>
<select id="ddlName" runat="server" multiple="true" onchange="ddl_OnChange(this);" class="multiselect-group">
</select>
</td>
</tr>
</table>
</table>
</ContentTemplate>
</asp:UpdatePanel>
I want a post back to fill name as per the roll number selection from database.
Pleas help.
Regards,
Ajay

Try adding Triggers to the update panel like as below:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlRoll" />
</Triggers>
here, control name is the dropdown that you have used. i.e., ddlRoll.
you can include this Trigger just before the opening of ContentTemplate tag.
Hope this helps!!

You need to use UniqueID to postback.
<ContentTemplate>
<table class="boxTable1" style="width: 100%;">
<tr style="height: 5px;">
<td colspan="2"> </td>
</tr>
<tr>
<td>
<asp:Label ID="lblBPSIOU" runat="server" Text="BPS IOU"></asp:Label></td>
<td>
<select id="ddlroll" runat="server" multiple="true" onclick="javascript:__doPostBack('<%= ddlroll.UniqueID %>','')" class="multiselect-group">
</select>
</td>
<td>
<asp:Label ID="lblName" runat="server" Text="Name"></asp:Label></td>
<td>
<select id="ddlName" runat="server" multiple="true" onchange="ddl_OnChange(this);" class="multiselect-group">
</select>
</td>
</tr>
</table>
</table>
</ContentTemplate>

Related

Enable to edit after a checkbox

I have a table with some information shown, but I would like to able to edit after I click the checkbox above.
<asp:Button ID="Backbtn" runat="server" Text="Back" Width="84px"
onclick="Backbtn_Click" />
<br /><br />
<asp:CheckBox ID="CheckBox1" runat="server" onclick="check" Text="Check"/>
<table class="T-Table" >
<tr>
<th colspan="6"><em>IT INTERNAL USE</em></th>
</tr>
<tr>
<td width="180px">Doc.No </td>
<td>:</td>
<td width="160px">
<asp:Label ID="DocNo" runat="server" Text="Label"></asp:Label>
</td>
<%-- <td width="180px">Job Complete Date </td>
<td>:</td>
<td width="160px">
</td> --%>
</tr>
<tr>
<td>Received Date :</td>
<td>:</td>
<td>
<asp:Label ID="RDate" runat="server" Text="Label"></asp:Label>
</td>
<td>Response Time (HR) :</td>
<td>:</td>
<td><asp:TextBox ID="Response_T" runat="server" TextMode="DateTimeLocal"></asp:TextBox>
</td>
</tr>
<tr>
<td>Remarks </td>
<td>:</td>
<td colspan="5"><asp:TextBox ID="Remarks" runat="server" Rows="5" TextMode="MultiLine"
Columns="80"></asp:TextBox></td>
</tr>
<tr>
<td>Cost charge to Department </td>
<td>:</td>
<td><asp:TextBox ID="Cost" runat="server" ></asp:TextBox></td>
<td>Status</td>
<td>:</td>
<td> <asp:DropDownList ID="Progress" runat="server">
<asp:ListItem Text="Done" Value="Done"></asp:ListItem>
<asp:ListItem Text="In Progress" Value="In Progress"></asp:ListItem>
<asp:ListItem Text="Pending" Value="Pending"></asp:ListItem>
</asp:DropDownList></td>
</tr>
Here are some html code. I would like to add a function so that all the information can be editable after I click the Checkbox.
Thank you
There is nothing to do with C# or Linq here (as you tagged).
Assuming you are working on an ASP.NET application
Enable the checkbox AutoPostback. ie, Set AutoPostback property of the checkbox to true.
Then on page load or checkbox checked change event, enable the textbox.
eg. name of text editor is txtRemarks and checkbox name to be chkRemarksEditor
on chkRemarksEditor Checked change event :-
txtRemarks.Enabled = chkRemarksEditor.Checked;

asp.net how to pass list of items to eval function?

this is my code to view products as list view inside each item in list view i want to view list of items how can i do this? i can not understand the concept of the eval function and i want to know if i can pass to it list items from code behind without data Bind or it basically depends on data-bind ?
<asp:ListView ID="mylistView" runat="server" GroupItemCount="3">
<EmptyDataTemplate>
<table id="Table2" runat="server">
<tr>
<td>
No data was returned.
</td>
</tr>
</table>
</EmptyDataTemplate>
<EmptyItemTemplate>
<td id="Td3" runat="server" />
</EmptyItemTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<ItemTemplate>
<table border="0" width="300" style="display: inline-block; background-color: Lime;">
<tr>
<td>
&nbsp
</td>
<td>
<a href='ContactUs.aspx'>
<image src='productsImg/<%# Eval("Pic_Path") %>' width="100" height="75" border="0">
</a>&nbsp
</td>
<td>
<a><b style="text-decoration: underline;">
<%# Eval("MenuName") %></b> </a>
<br />
want to view here list of items
I
</td>
</tr>
</table>
</ItemTemplate>
<LayoutTemplate>
<table id="Table1" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="groupPlaceholderContainer" runat="server">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr2" runat="server">
<td id="Td2" runat="server">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
this is code behind...
dataSource.ConnectionString = connetionString;
dataSource.SelectCommand = "SELECT * FROM tbl_WebMenu where MenuID like'3_';";
mylistView.DataSource = dataSource;
mylistView.DataBind();
thanks in advance.
Eval is used to bind to an UI control that is supposedly read only. it can be used to set any type of property of control.
The complete syntax is "Databinder.Eval", it has to be used in conjunction with databind.
Look at this example.
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblRead" runat="server" Text='<%# Eval("FieldName") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
you can even set a property of control using eval. it provides flexibility.
But there is a downside of eval as it uses reflection to evaluate the expression.
Read more here http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx#remarksToggle

<asp:UpdatePanel > doesn't work inside a table <tr>?

I have a problem getting an <asp:UpdatePanel..> to work inside a <table>.. <tr> </tr> structure and I don't know why. When the UpdatePanel is commented out everything works fine, but when I un-comment the UpdatePanel the contents of the <tr> </tr> tag doesn't even show up in Visual Studio 2010. This content does display when I run the web page but the UpdatePanel doesn't work. Non of my other web pages in this project have this problem but, then again, I use <div>s instead of <table>s in them.
One other thing. The is in my MasterPage.
Here is my script:
<asp:UpdatePanel ID="W9UpdatePanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<tr>
<td colspan="6">
<div class="branchSetupSectionTitle">W-9 Information:</div>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnDownloadW9Pdf" runat="server"
Text="Download W-9" onclick="btnDownloadW9Pdf_Click" AutoPostBack="True" />
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator24"
runat="server" ControlToValidate="txtFirstPaymentAmount" Display="Dynamic"
ErrorMessage="The dollar amount you entered is in the wrong format."
ForeColor="Red" ValidationExpression="^\d+(\.\d\d)?$">*</asp:RegularExpressionValidator>--%>
<asp:CheckBox ID="chkW9FormSubmitted" runat="server" AutoPostBack="True"
oncheckedchanged="chkW9FormSubmitted_CheckedChanged"
Text=" I have submitted this W-9 Form" />
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
The event fires for both the button and the checkbox but the entire page is refreshed.
Thanks for your help.
UpdatePanel needs to render a div or span in order to function correctly. Since neither of these elements can be rendered between table rows, UpdatePanel does not have a placeholder to render the postback response html, and thus it doesn't work.
A workaround in your case may be to see which part of your page does not need to be inside the update panel and leave it outside. You could leave just the contents of <td colspan="2"> inside the UpdatePanel.
<asp:ScriptManager ID="scm" runat="server">
</asp:ScriptManager>
<fieldset>
<legend>Truck Master Entry Form</legend>
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<table cellpadding="2" cellspacing="1">
<tr>
<td align="right">
Truck no :
</td>
<td align="left">
<asp:TextBox ID="truckno" runat="server" Width="120px" Height="20px" />
</td>
</tr>
<tr>
<td align="right">
Size :
</td>
<td align="left">
<asp:DropDownList ID="drptrucksize" runat="server" Width="120px" Height="20px" DataValueField="WEIGHT"
DataTextField="SIZE" OnSelectedIndexChanged="drptrucksize_SelectedIndexChanged"
AutoPostBack="true" />
</td>
</tr>
<tr>
<td align="right">
Type :
</td>
<td align="left">
<asp:TextBox ID="txttrucktype" runat="server" Width="120px" Height="20px" />
</td>
</tr>
<tr>
<td align="right">
Weight :
</td>
<td align="left">
<asp:TextBox ID="txtweight" runat="server" Width="120px" Height="20px" />
</td>
</tr>
<tr>
<td align="right">
</td>
<td align="left">
<asp:Button ID="btnsave" runat="server" Text="Save" Width="100px" Height="50px" />
<asp:Button ID="btncancel" runat="server" Text="Cancel" Width="100px" Height="50px" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
The update panel need to be put outside the table. Look at
Mohammad Shahnawaz's code.

ValidatorCalloutExtender and ModalPopupExtender Issues on MasterPage

I have just created a website with a MasterPage. I have two conditions that will illustrate my problem:
Condition 1:
I have added a ModalPopupExtender on website.master. It has three fields and each field has a RequiredFieldValidator and a ValidatorCalloutExtender.
Condition 2:
I have a few different pages where you can click on a registration link. When you click the registration link, a registration form will appear. This form also has RequiredFieldValidators and ValidatorCalloutExtenders for each field.
Problem:
If I open a registration form and want to place my feedback, I click on the feedback button. The feedback modal popup displays. If I click on the submit button without filling the feedback form, it should give me the error in ValidatorCalloutExtender format on the ModalPopupExtender panel. However, it doesnt show me any error but the ValidatorCalloutExtender does show on the registation form along with respective validation.
<cc1:ModalPopupExtender CancelControlID="lnk_cancel" ID="popup_change_password" BackgroundCssClass="modalBackground"
runat="server" TargetControlID="ImageButton1" PopupControlID="panel_change_password">
</cc1:ModalPopupExtender>
<asp:Panel ID="panel_change_password" runat="server" Style="display: none; height: 400px;
width: 400px; padding-left:30px; background-repeat:no-repeat;" BackImageUrl="~/Images/background.gif">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="3" valign="top">
<table cellpadding="0" cellspacing="0" width="400px">
<tr>
<td align="right">
<asp:ImageButton ID="lnk_cancel" runat="server" ImageUrl="Images/close.gif" Height="30px"
Width="30px" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lbl_new_password" runat="server" Text="Your feedback is important to us."
CssClass="login_font1"></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_name" runat="server" Text="Name" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_name" runat="server" CssClass="Textbox_Styles"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_email" runat="server" Text="Email Address" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_email" runat="server" CssClass="Textbox_Styles"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl_comment" runat="server" Text="Comments" CssClass="Label_Styles"></asp:Label>
</td>
<td>
:
</td>
<td>
<asp:TextBox ID="txt_comment" runat="server" CssClass="Textbox_Styles" Height="120px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
</table>
</asp:Panel>
Put the above code in an UpdatePanel with UpdateMode="Conditional" and ChildrenAsTriggers="False".
So it will look something like :
<asp:UpdatePanel ID="sbsModalExtenderUpdatePanel" runat="server" UpdateMode="Conditional"
Visible="False" ChildrenAsTriggers="False">
<ContentTemplate>
<asp:Panel ID="StepByStepBookingPanel" runat="server" Enabled="false" EnableViewState="false"
Style="display: block" CssClass="mediumModalPopup" ScrollBars="Auto" Width="800px"
Height="300px" ViewStateMode="Enabled">
<div id="clientCoordDiv" runat="server">
<table id="StepByStepTable" runat="server">
etc...
</table>
</div>
</asp:Panel>
<ajax:ModalPopupExtender ID="mpeStepByStepBooking" runat="server" BackgroundCssClass="modalBackground"
PopupControlID="StepByStepBookingPanel" CancelControlID="BtnCancel" OnCancelScript="ClearStepByStepPopup"
TargetControlID="hdnStepByStepButton" DropShadow="true" BehaviorID="modalwithinput" />
<asp:CompareValidator ID="ClientCoordinatorCompareValidator" runat="server" ErrorMessage="Please select a Client Coordinator"
ControlToValidate="ddlClientCoordinator" Display="None" Operator="NotEqual" SetFocusOnError="True"
Type="Integer" ValueToCompare="0" ValidationGroup="SelectionRequired">
</asp:CompareValidator>
<asp:CompareValidator ID="CVOCoordinatorCompareValidator" runat="server" ErrorMessage="Please select a CVO Coordinator"
ControlToValidate="ddlCVOCoordinator" Display="None" Operator="NotEqual" ValueToCompare="0"
Type="Integer" SetFocusOnError="True" ValidationGroup="SelectionRequired">
</asp:CompareValidator>
<ajax:ValidatorCalloutExtender ID="CompareClientCoordinatorExt" runat="server" Enabled="True"
TargetControlID="ClientCoordinatorCompareValidator" BehaviorID="ClientValidatorExt">
</ajax:ValidatorCalloutExtender>
<ajax:ValidatorCalloutExtender ID="CVOCoordinatorCompareValidatorExt" BehaviorID="CVOValidatorExt"
runat="server" Enabled="True" TargetControlID="CVOCoordinatorCompareValidator">
</ajax:ValidatorCalloutExtender>
</ContentTemplate>
</asp:UpdatePanel>
This will keep the dialog up while you validate it. Unfortunately, I do not have the full solution since my validator messages are not displaying. So far, from what I am getting on the Net it is a problem with the Ajax library. Ugly!
Oh well, hope this helps someone...

FileUpload not working in update panel(modal popup extender)

i am developing web application and contain modal popup extender in which update panel made and it contain file upload control but file upload control not working in it.
This is my modal popup which contain fileupload control
and my modal popup source code
<cc1:ModalPopupExtender ID="AddNews" runat="server" PopupControlID="pnlPopUp1" BehaviorID="AddNews"
TargetControlID="btnNews" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopUp1" runat="server" CssClass="modalPopup" Height="450px" Width="660px"
Style="display:none; z-index: 100000">
<asp:UpdatePanel ID="Upanel1" runat="server">
<ContentTemplate>
<div>
<table cellpadding="0" cellspacing="0" width="100%">
<tr style="height: 35px;">
<td style="width:170px">
</td>
<td style="text-align: center">
<h1>
Add News</h1>
</td>
<td style="text-align: right">
<asp:ImageButton ID="ImageButton2" AlternateText="Close Image" runat="server" ImageUrl="~/images/delete_32i.GIF"
OnClientClick="return closePopup('News')" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblAddNewsError" runat="server" Text="" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td>News Title:</td><td>
<asp:TextBox ID="txtNewTitle" Width="250px" runat="server" MaxLength="500"></asp:TextBox>
</td><td>
<asp:RequiredFieldValidator ID="rfvNewsTitle" runat="server"
ControlToValidate="txtNewTitle" ErrorMessage="*" ToolTip="Enter news title"
ValidationGroup="AddNews"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Upload News Video</td><td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td><td><asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="FileUpload1"
ErrorMessage="Invalid video File"
ValidationExpression="^([0-9a-zA-Z_\-~ :\\])+(.avi|.AVI|.wmv|.WMV|.flv|.FLV|.mpg|.MPG|.mp4|.MP4)$"
ToolTip="Only allow avi, wmv, flv, mpg, mp4 formats video files"
ValidationGroup="AddNews"></asp:RegularExpressionValidator></td>
</tr>
<tr style="height: 5px">
<td>
</td>
</tr>
</table>
<div>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="width: 675px">
<FCKeditorV2:FCKeditor ID="FCKAddNewsContent" basepath="~/fckeditor/" runat="server" Height="300px"></FCKeditorV2:FCKeditor>
</td>
<td valign="top">
</td>
</tr>
<tr>
<td style="text-align:right">
<asp:Button ID="btnAddNews" runat="server" Text="Add News"
onclick="btnAddNews_Click" ValidationGroup="AddNews" />
<asp:Button ID="btnClose"
runat="server" Text="Close" OnClientClick="return closePopup('News')"
CausesValidation="False" /></td><td></td>
</tr>
</table>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnAddNews" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>
as you see my one button also mentioned in postback trigger as i click on this button the result which i got is
can anyone help me out from this problem.
only one thing i just need in web.config and make it working
<httpRuntime executionTimeout="90" maxRequestLength="2000000" useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="8192"/>
Point up my answer if you got your solution.
You can set Triggers on update panel. After that you can get file at server side.
<Triggers>
<ajax:PostBackTrigger ControlID="btnAddNews" />
</Triggers>
Hope it will help.

Categories