I am trying to use a repeater and use ajax instead of the "EnableEventValidation='true'" but I get the error below on page unload. When I click on the button in the repeater the repeater1_ItemCommand does not get referenced
Error:
System.Collections.ListDictionaryInternal System.ArgumentException:
Invalid postback or callback argument. Event validation is enabled
using in configuration or <%#
Page EnableEventValidation="true" %> in a page
Code:
<asp:ToolkitScriptManager ID="MainSM" EnablePageMethods="true" runat="server" ScriptMode="Release" LoadScriptsBeforeUI="true">
</asp:ToolkitScriptManager>
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<table id="myTable" width="700" border="1" class = "mMMGrid" frame="box">
<th align=left>Page Image</th><th align=left>Page #</th><th align=left >Page Sequnce</th><tbody>
<tr>
<td width="15%">
<div id = "dPage" runat="server" >
<asp:ImageButton ID="imbtnCourseLink" runat="server" ImageUrl='<%#imPath(DataBinder.Eval(Container, "DataItem.ChunkFilePath"))%>' OnClick="imlink2" Width="75px" Height="75px" />
</div>
</td>
<td width="15%">
<strong>Pages</strong> : <asp:label ID="lblPage" Text='<%# Eval("Page")%>' runat="server"></asp:label> <br/>
</td>
<td width="65%">
<asp:ImageButton ID="imbtUp" runat="server" ImageUrl="~/SiteImages/go-up.png" Width="40" height="40" CommandName="UP" CommandArgument='<%# Eval("Page")%>'/>
<asp:ImageButton ID="imbtDown" runat="server" ImageUrl="~/SiteImages/go-down.png" Width="40" Height="40" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<triggers>
<asp:asyncpostbacktrigger controlid="imbtUp" eventname="Click" />
<asp:asyncpostbacktrigger controlid="Repeater1" eventname="ItemCommand" />
</triggers>
</asp:UpdatePanel>
<br />
</td>
</tr>
</tbody>
</table>
</ItemTemplate>
</asp:Repeater>
Related
I have Listview control on webform.aspx page with below defination...
<asp:ListView runat="server" ID="dispalyProducts">
<LayoutTemplate>
<table runat="server" id="table1">
<tr runat="server" id="itemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<%-- Data-bound content. --%>
<asp:Label runat="server" Text='<%#Eval("ProductName") %>' />
<br/>
<asp:TextBox runat="server" />
<br/>
<asp:Label runat="server" Text='<%#Eval("ProductID") %>' />
<br/>
<asp:Button runat="server" Text="Add TO cart" OnClientClick="AddToCart('<%#Eval("ProductID") %>');return false;"/>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
Whent he program runs, it creates a list of product ID, name and a button.
I want to use this button as "add to cart" functionality. so when a user clicks on button, i want to call a javascript function with productID, and textbox value (as item id and quantity).
How can I pass these values to javascript function in listview.
<asp:Button ... OnClientClick='AddToCart(\"<%#Eval("ProductID") %>\", \"<%#Eval("ProductName") %>\");return false;'/>
You can pass values as parameters to your js function.
I have a table and inside the table i have an asp repeater.
<table id="repeaterTable">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td>
<b>Not Feasible:</b> <asp:RadioButton ID="notfeasibleRadioBtn" runat="server"/> <b>Feasible:</b> <asp:RadioButton ID="feasibleRadioBtn" runat="server" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<asp:UpdatePanel ID="radpnl1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Repeater ID="rpt_Template" runat="server">
<HeaderTemplate>
<table id="tblusers" width="100%" cellpadding="2" cellspacing="2">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="20%" class="table_row2">
Name :
</td>
<td class="table_row2">
<input type="text" id="txt_template" name="txt_template" value='<%# DataBinder.Eval(Container.DataItem, "TemplateName") %>'
maxlength="200" />
<input type="hidden" id="hdnDeletedIds" name="hdnDeletedIds" value="" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
I am new to Jquery. I want to know if i can select all the input fields above with id="txt_template" to compare their name using a Jquery function. As this is is under <asp:repeater> control, I'm not sure how to achieve this.
Inside the repeater, You need to use class instead of id. I'm not really sure but I thing the id you give to a server control with runat=server is not essentially the rendered id.
So use a class as follows
<asp:UpdatePanel ID="radpnl1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Repeater ID="rpt_Template" runat="server">
<HeaderTemplate>
<table id="tblusers" width="100%" cellpadding="2" cellspacing="2">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="20%" class="table_row2">
Name :
</td>
<td class="table_row2">
<input type="text" class='aSuperInput' id="txt_template" name="txt_template" value='<%# DataBinder.Eval(Container.DataItem, "TemplateName") %>'
maxlength="200" />
<input type="hidden" id="hdnDeletedIds" name="hdnDeletedIds" value="" />
</td>
</tr>
</table>
</ContentTemplate>
JQuery
$('.aSuperInput').change(function(){
//----
});
or
$('.aSuperInput').select(function(){
//----.blur(), .focus(), .unblur(), ect.
});
I would like to show to two different repeaters in same div but once at a time.
<div id="tab1" class="tab_content">
<div class="comment1">
<div class="comments_header">Our Previous Comments</div>
<div class="prev_comments">
<asp:Panel ID="Panel2" runat="server">
<asp:Repeater ID="rptcomment" runat="server" >
<HeaderTemplate>
<table style="background-color:antiquewhite; width:600px; cellpadding="0" >
<tr >
<td colspan="2"></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width:5px; border-bottom:dotted" >
<img src="../images/prople.jpg" style="height: 77px; width: 72px" />
</td>
<td style=" border-bottom:dotted">
<asp:Label ID="lblname" runat="server" Text='<%#Eval("fullname") %>' />
on
<asp:Label ID="Label2" runat="server" Text='<%#Eval("datetime") %>' Font-Bold="true"/>
<br />
<asp:Label ID="lblcomment" runat="server" Text='<%#Eval("comment") %>'/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
<asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical" Height="457px" Width="607px">
<asp:Repeater ID="RepterDetails" runat="server" >
<HeaderTemplate>
<table style="background-color:darkturquoise; width:600px; cellpadding="0">
<tr >
<td colspan="2">
<center> <b>Our Previous Comments</b></center>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width:5px; border-bottom:dotted" >
<img src="http://localhost:1411/images/prople.jpg" style="height: 77px; width: 72px" />
</td>
<td style=" border-bottom:dotted">
<asp:Label ID="lblname" runat="server" Text='<%#Eval("fullname") %>' />
on
<asp:Label ID="Label2" runat="server" Text='<%#Eval("datetime") %>' Font-Bold="true"/>
<br />
<asp:Label ID="lblcomment" runat="server" Text='<%#Eval("comment") %>'/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
<center>
<asp:Label ID="Label1" runat="server" Font-Bold="True" />
<asp:HyperLink ID="linkPrev" runat="server">Previous Page</asp:HyperLink>
<asp:HyperLink ID="linkNext" runat="server">Next Page</asp:HyperLink>
</center>
<div class="clear"></div>
</div>
</div>
</div>
In the above code when first page loads I would like to show repeater which are in panel2 and when user clicks on link previous comment I would like to show repeater of panel1 only but in the same div and same page.How to solve this problem?
Since you have each repeater inside an asp:Panel, this will be as easy as set the Visible attribute of the pertinent panel to false.
You can also archive this by using CSS styles with display: none; or visibility: hidden.
I have 2 jQuery script in one page jQuery Dialog and jQuery slideToggle inside the dialog box, jQuery dialog is working but after hitting button to open jQuery Dialog inside the dialog box there will be a button to slideToggle a div but its not working I tried to move slideToggle outside the dialog and it works. I don't know whats going on inside the dialog box if someone can help me to solve my problem
jQuery Dialog
<script type="text/javascript">
$(function () {
$("#dialog").dialog({
appendTo: "form",
autoOpen: false,
width: 630,
height: 700,
draggable: false,
resizable: false,
modal: true
});
$("#btnaddnew").click(function () {
$("#dialog").dialog("open");
return false;
});
});
</script>
jQuery slideToggle
<script type="text/javascript">
$(document).ready(function () {
$("#Div1").hide();
$("#Button1").click(function () {
$("#Div1").slideToggle();
return false;
});
});
</script>
dialog div + slideToggle div inside the jQuery dialog
<div id="dialog" title="Classification">
<asp:UpdatePanel ID="addpanel" runat="server">
<ContentTemplate>
<table>
<tr>
<td><div id="registerform">
<table align="center" style="margin-top:10px" width="600">
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem Selected="True">Choose Classification</asp:ListItem>
<asp:ListItem Value="Resident">Resident</asp:ListItem>
<asp:ListItem Value="Business">Business</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
<table>
<tr>
<td><div id="divresident" runat="server" visible="false">
<table style="margin-top:10px; margin-bottom:10px">
<tr>
<td width="300" style="text-align:left"><asp:Label ID="lbAddress" runat="server" Text="Address"></asp:Label></td>
<td width="300"><asp:TextBox ID="txtAddress" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
</tr>
<tr>
<td style="text-align:left"><asp:Label ID="lbUserEntry" runat="server" Text="Number of House occupant"></asp:Label></td>
<td><asp:TextBox ID="txtUserEntry" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
</tr>
<tr>
<td style="text-align:left"><asp:Button ID="btnAddOccupant" runat="server" Text="+" />
<asp:Label ID="lbres5" runat="server" Text="Add Occupant"></asp:Label></td>
</tr>
<tr>
<td>
<div id="divOccupantProfile" style="display: none">
<asp:Label ID="OPfamilyname" runat="server" Text="Family Name"></asp:Label>
<asp:TextBox ID="textOPfamilyname" runat="server"></asp:TextBox><br />
<asp:Label ID="OPfirstname" runat="server" Text="First Name"></asp:Label>
<asp:TextBox ID="textOPfirstname" runat="server"></asp:TextBox><br />
<asp:Label ID="OPmiddlename" runat="server" Text="Middle Name"></asp:Label>
<asp:TextBox ID="textOPmiddlename" runat="server"></asp:TextBox><br />
<asp:Label ID="OPmaritalstatus" runat="server" Text="Marital Status"></asp:Label>
<asp:DropDownList ID="ddlOPmaritalstatus" runat="server" >
<asp:ListItem></asp:ListItem>
<asp:ListItem>Married</asp:ListItem>
<asp:ListItem>Single</asp:ListItem>
<asp:ListItem>Divorced</asp:ListItem>
</asp:DropDownList><br />
<asp:Label ID="OPoccupation" runat="server" Text="Occupation"></asp:Label>
<asp:TextBox ID="textOPoccupation" runat="server"></asp:TextBox><br />
<asp:Label ID="OPrelationship" runat="server" Text="Relationship"></asp:Label>
<asp:DropDownList ID="ddlOPrelationship" runat="server" >
<asp:ListItem></asp:ListItem>
<asp:ListItem>Wife</asp:ListItem>
<asp:ListItem>Daughter</asp:ListItem>
<asp:ListItem>Son</asp:ListItem>
<asp:ListItem>Father</asp:ListItem>
<asp:ListItem>Mother</asp:ListItem>
<asp:ListItem>House helper</asp:ListItem>
<asp:ListItem>Driver</asp:ListItem>
</asp:DropDownList>
</div>
<div id="holder">
</div>
</td>
</tr>
</table>
</div></td>
</tr>
</table>
<table>
<tr>
<td><div id="divbusiness" runat="server" visible="false">
<table width="600" style="margin-top:10px; margin-bottom:10px">
<tr>
<td width="300" style="text-align:left"><asp:Label ID="lbbus1" runat="server" Text="Registered Business Name" ></asp:Label></td>
<td width="300"><asp:TextBox ID="txtbus2" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
</tr>
<tr>
<td width="300" style="text-align:left"><asp:Label ID="lbbus3" runat="server" Text="Address"></asp:Label></td>
<td width="300"><asp:TextBox ID="txtbus4" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
</tr>
<tr>
<td width="300" style="text-align:left"><asp:Label ID="lbbus5" runat="server" Text="Structure"></asp:Label></td>
<td width="300"> </td>
</tr>
<tr>
<td width="300" style="text-align:left"><asp:Label ID="lbbus6" runat="server" Text="SEC No./DTI number"></asp:Label></td>
<td width="300"><asp:TextBox ID="txtbus7" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
</tr>
<tr>
<td width="300" style="text-align:left"><asp:Label ID="lbbus8" runat="server" Text="Nature of Business"></asp:Label></td>
<td width="300"><asp:TextBox ID="txtbus9" class="basetxt" runat="server" Width="290"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" style="text-align:left">
<div>
<asp:Button ID="Button1" runat="server" Text="+" />
<asp:Label ID="Label1" runat="server" Text="Add Phone"></asp:Label>
<div id="Div1" style="display: none">
<asp:Label ID="Label2" runat="server" Text="Landline work"></asp:Label>
<asp:TextBox ID="TextBox1" class="basetxt" runat="server" ></asp:TextBox><br />
<asp:Label ID="Label3" runat="server" Text="Handphone personal" ></asp:Label>
<asp:TextBox ID="TextBox2" class="basetxt" runat="server"></asp:TextBox><br />
<asp:Label ID="Label4" runat="server" Text="Handphone work"></asp:Label>
<asp:TextBox ID="TextBox3" class="basetxt" runat="server"></asp:TextBox>
</div>
</div>
</td>
</tr>
</table>
</div></td>
</tr>
</table>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
.click won't work on later loaded elements, try it like this, replace:
$("#Button1").click(function () {
With:
$("body").on('click', '#Button1', function() {