Onclick is not working in asp:Button? - asp.net

<script type="text/javascript">
$(function () {
$('#LogStatusLable').click(function () {
$('#LoginPanel').slideToggle("slow");
});
$('#LoginPanel').hide();
});
</script>
<div id="LoginPanel">
<br />
<div class="grid_6">
<br />
<a>New User Registration</a>
</div>
<table class="grid_6">
<tr>
<td>Email-ID</td>
<td>
<asp:TextBox runat="server" ID="UsernameTextBox" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td>Password</td>
<td>
<asp:TextBox runat="server" ID="PasswordTextBox" TextMode="Password" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2"><asp:Label runat="server" ID="LoginValidation" Text=""></asp:Label> </td>
</tr>
<tr>
<td>
<asp:Button ID="Login" runat="server" UseSubmitBehavior="true" Text="Login"
CssClass="buttoncss" onclick="Login_Click" />
<br /> <br />
</td>
</tr>
</table>
</div>
protected void Login_Click(object sender, EventArgs e)
{
if (UsernameTextBox != null && PasswordTextBox.Text != null)
{
if (_user.GetandSetUserDetails(UsernameTextBox.Text, PasswordTextBox.Text))
{
}
else
{
LoginValidation.Text = "Invalid username or password";
}
}
else
{
LoginValidation.Text = "Enter the Username and Password";
}
}
I used the jquery to slideup and slidedown the div tag. Its working correctly but the inside of the div tag i used the asp:button its not functioning well. onclick property is dosent work. Please help me to find a solution.
Thank you.

remove any duplicate form tag in page.

Related

Prevent Bootstrap Collapse toggle after postback

I am using bootstrap collapse in my project,in that collapse I have some buttons and dropdowns but when I click on any button or change dropdown index, postback occurs and collapse got uncollapsed,How can I stop this ?
Here is my Code
<h4>Search Training Profile<br />
</h4>
<div id="div_search" class="collapse" style="overflow-x: auto;">
<table class="table table-bordered table-striped">
<tr>
<td>Employee Name</td>
<td>
<asp:TextBox runat="server" ID="txt_name"></asp:TextBox>
<span class="err">optional</span>
</td>
<td>e.g First Name, Middle Name, Last Name</td>
</tr>
<tr>
<td>Designation</td>
<td><span class="err"></span>
<asp:DropDownList runat="server" ID="DDL_Desig" OnSelectedIndexChanged="DDL_Desig_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
<span class="err">optional</span>
</td>
<td>
<asp:TextBox runat="server" ID="txt_desig" ReadOnly="true"></asp:TextBox>
<asp:Button Text="Clear" runat="server" />
</td>
</tr>
<tr>
<td>Location</td>
<td>
<asp:DropDownList runat="server" ID="DDL_Loc" OnSelectedIndexChanged="DDL_Loc_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem>Select</asp:ListItem>
</asp:DropDownList>
<span class="err">optional</span>
</td>
<td>
<asp:TextBox runat="server" ID="txt_loc" ReadOnly="true"></asp:TextBox>
<asp:Button Text="Clear" runat="server" />
</td>
</tr>
<tr>
<td>Division</td>
<td>
<asp:DropDownList runat="server" ID="DDL_Divis" OnSelectedIndexChanged="DDL_Divis_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
<span class="err"> optional </span>
</td>
<td>
<asp:TextBox runat="server" ID="txt_divis" ReadOnly="true"></asp:TextBox>
<asp:Button Text="Clear" runat="server" />
</td>
</tr>
<tr>
<td>Department</td>
<td>
<asp:TextBox runat="server" ID="tx"></asp:TextBox>
<span class="err">optional</span></td>
<td>e.g ISD, MKT, HR etc</td>
</tr>
<tr>
<td>Filter By</td>
<td>
<asp:DropDownList runat="server" ID="DDL_Assc">
</asp:DropDownList>
</td>
<td>e.g OLP, SOLC, MAF, etc</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3" style="text-align:center;">
<asp:Button Text="Search" runat="server" CssClass="btn" />
<asp:Button Text="Reset" runat="server" CssClass="btn" />
</td>
</tr>
</table>
</div>
Create public variable
string state = "collapse";
during the postback or dropdown changed set the value as
state = "expand";
and aspx page use this as below:-
<div id="div_search" class='<%= state %>' style="overflow-x: auto;">
Aditya's answer helped me initially and is a nice solution. As my code evolved wrapping the div inside an update panel and having the collapse div contain a couple calendar controls that cause postbacks to refresh data in a grid, I came up with another solution I thought worth sharing as it is handled server side only.
<asp:Panel ID="pnlDateRange" ClientIDMode="Static" runat="server" CssClass="collapse col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div id="divFrom" class="col-xs-12 col-sm-12 col-md-2 col-md-offset-4 col-lg-2 col-lg-offset-4">
<asp:Calendar ID="cStartDate" runat="server" CssClass="calendar" Font-Size="X-Small"
DayNameFormat="FirstTwoLetters" DayHeaderStyle-Font-Bold="false"
TitleStyle-Font-Bold="true" TitleStyle-Font-Size="Small" Caption="From"
OnSelectionChanged="cStartDate_SelectionChanged">
<SelectedDayStyle Font-Bold="true" />
<OtherMonthDayStyle ForeColor="SlateGray" />
</asp:Calendar>
</div>
<div id="divTo" class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
<asp:Calendar ID="cEndDate" runat="server" CssClass="calendar" Font-Size="X-Small"
DayNameFormat="FirstTwoLetters" DayHeaderStyle-Font-Bold="false"
TitleStyle-Font-Bold="true" TitleStyle-Font-Size="Small" Caption="To"
OnSelectionChanged="cEndDate_SelectionChanged">
<SelectedDayStyle Font-Bold="true" />
<OtherMonthDayStyle ForeColor="SlateGray" />
</asp:Calendar>
</div>
</asp:Panel>
The control was originally an ordinary with the same classes applied, it is the collapse target. In the c# on server side I have defined a private boolean variable set to true in all cases when the code loads to run. In the OnPreRender event I do this:
if (_collapseRange)
{
pnlDateRange.CssClass = pnlDateRange.CssClass.Replace("collapse in", "collapse");
}
else
{
if (!pnlDateRange.CssClass.Contains("collapse in"))
{
pnlDateRange.CssClass = pnlDateRange.CssClass.Replace("collapse", "collapse in");
}
}
I know it's an old question, but i did it this way.
Maybe not the best way, but it works for me.
Just call the method when ever you need it.
It gets a bit messy when you got a lot to collapse.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetTextForInfoboxFrontPage();
multiCollapseExample1.Attributes["class"] = "collapse";
annualCollapse.Attributes["class"] = "collapse";
infoBox.Attributes["class"] = "collapse";
}
}
private void CollapseAllButAnnual()
{
annualCollapse.Attributes["class"] = "collapse in";
infoBox.Attributes["class"] = "collapse";
logoUpload.Attributes["class"] = "collapse";
}

how to put validation for checkbox in asp.net?

<tr>
<td>
<asp:CheckBox ID="checkdoc" runat="server" Checked="false" />:Document
</td>
<td>
<asp:CheckBox ID="checktwocheque" runat="server" Checked="false" />:Two Cheques
</td>
<td>
<asp:CheckBox ID="checkIdprf" runat="server" Checked="false" />:ID Proof
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="checkpancrd" runat="server" Checked="false" />:PAN Card
</td>
<td>
<asp:CheckBox ID="checkAddrssprf" runat="server" Checked="false" />:Address Proof
</td>
</tr>
<tr>
<td colspan="4" align="center">
<asp:Button ID="btnfarmrecordsave" runat="server" Text="Save" OnClientClick="return Validations();" OnClick="btnfarmrecordsave_Click" />
</td>
</tr>
I have written code like this for choosing at least one checkbox. How can I write code for validation in javascript?. I want to display one message "Please select at least one checkbox" if user hasn't selected any checkbox?
Please try to implement the Validations function like this:
<script type="text/javascript">
function Validations() {
if (!(document.getElementById("<%=checkdoc.ClientID%>").checked ||
document.getElementById("<%=checktwocheque.ClientID%>").checked ||
document.getElementById("<%=checktwocheque.ClientID%>").checked ||
document.getElementById("<%=checkIdprf.ClientID%>").checked ||
document.getElementById("<%=checkpancrd.ClientID%>").checked ||
document.getElementById("<%=checkAddrssprf.ClientID%>").checked)) {
alert('You have to select atleast one choice!');
return false;
} else {
return true;
}
}
</script>
Javascript code :
if (!$(':checkbox').is(':checked')) {
alert('please, select ...');
}
<style>
.abc{
display:box
//any style you want to put
}
</style>
<script>
function Validations()
{
if ($('input.abc').not(':checked').length > 0)
{
alert("please select atleast one checkbox");
}
}
</script>
<tr>
<td>
<asp:CheckBox ID="checkdoc" runat="server" Checked="false" class="abc"/>:Document
</td>
<td>
<asp:CheckBox ID="checktwocheque" runat="server" Checked="false" class="abc"/>:Two Cheques
</td>
<td>
<asp:CheckBox ID="checkIdprf" runat="server" Checked="false" class="abc"/>:ID Proof
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="checkpancrd" runat="server" Checked="false" class="abc"/>:PAN Card
</td>
<td>
<asp:CheckBox ID="checkAddrssprf" runat="server" Checked="false" class="abc"/>:Address Proof
</td>
</tr>
<tr>
<td colspan="4" align="center">
<asp:Button ID="btnfarmrecordsave" runat="server" Text="Save" OnClientClick="return Validations();"
OnClick="btnfarmrecordsave_Click" />
</td>
</tr>
function Validations()
{
var chk = document.getElementsByTagName('input');
for (var i = 0; i < chk.length; i++)
{
if (chk[i].type == 'checkbox')
{
if (chk[i].checked) {return true}
}
}
alert("Please select atleast one checkbox");
return false;
}

ASP ImageButton in Repeater not firing

I have a usercontrol that contains a repeater. Within this repeater there is an ImageButton, that when clicked is supposed to call an expand method. However, the ImageButton is not firing anything, not even a PostBack.
AutoEventWireUp on the usercontrol is set to true. the Repeater ItemDataBound is set in Markup. But even with all of that the ImageButton still will not fire any type of action.
What would be the reason that no firing is occuring at all?
Below is the HTML Markup:
<%# Control Language="vb" AutoEventWireup="true" Codebehind="BiddersGroupList.ascx.vb"
Inherits="FXWB.BidPackage.BiddersGroupList" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%# Register TagPrefix="fxwb" TagName="GridLabel" Src="~/Secure/Controls/GridLabel.ascx" %>
<telerik:RadCodeBlock ID="rcbScripts" runat="server">
<script>
function pb(ctrl,FolderId, B, BID, CID)
{
// debugger;
var lblid = ctrl.parentElement.parentElement.cells[7].childNodes[0].id;
SethdnUpdatedValues(lblid, (B=='WB') ? 'Yes' : 'No');
NoRefreshRequestProcessor_SendRequest('changeBidStatus:'+B+':'+BID+':'+CID);
}
function ir(ctrl,FolderId, BID, CID)
{
debugger;
if(ctrl.checked ==true)
B = '1';
else
B = '0';
NoRefreshRequestProcessor_SendRequest('changeAdminIsRceived:'+B+':'+BID+':'+CID);
}
function pw(BPID, SUID, FID){
var BID ='Owner';
window.open('Bidpackage/ReplyToBid.aspx?BPID='+ BPID + '&SUID='+SUID+'&BID='+BID + '&FID='+ FID + '&a=edit','_blank','height=600,width=800,status=yes,toolbar=no,menubar=no,location=no, scrollbars=yes, resizable = yes');
}
function be(BID, BPID,CSI){
window.open('Bidpackage/EditBidderInfo.aspx?BidderID='+BID+'&BidPackageID='+BPID+'&CSI='+CSI,'bidder_edit','height=550,width=950,status=yes,toolbar=no,menubar=no,location=no, scrollbars=yes, resizable = yes')
}
function one(sender,NID,CsiValue,lblid){
//debugger;
NoteLabelID=lblid;
var url = 'Bidpackage/BidderNoteEdit.aspx?NoteID='+escape(NID)+'&CSI='+CsiValue;
var Top = (screen.availHeight / 2) - 100; //getY(sender) - document.getElementById('FolderBody').scrollTop + 226;
var Left = (screen.availWidth / 2) - 150; //getX(sender) + 280;
var params = 'height=200, width=300, location=0, top='+Top+', left='+Left+', status=0, scrollbars=0, toolbar=0';
var arr=NID.split(':');
window.open(url,'BDR_NOTE_'+escape(arr[0]),params);
//window.open(url,'BDR_NOTE_'+escape(NID.replace(':','_')),params);
//window.open(url,params);
}
function SelectAll(chkMain)
{
//debugger;
var mainchk = chkMain.getAttribute("Division");
var chk = document.documentElement.getElementsByTagName("input");
var i;
for(i=0;i<chk.length; i++)
{
if(chk[i].type=='checkbox')
{
csiChild = chk[i].getAttribute("Division");
if (csiChild != null)
{
if(csiChild == mainchk)
{
if(chkMain.checked == true)
{
chk[i].checked = true;
SelectCodes(chk[i])
}
else
{
chk[i].checked = false;
SelectCodes(chk[i])
}
}
}
}
}
}
function SelectCodes(chkMain)
{
// debugger;
var mainchk = chkMain.getAttribute("CSI");
var chk = document.documentElement.getElementsByTagName("input");
var i;
for(i=0;i<chk.length; i++)
{
if(chk[i].type=='checkbox')
{
csiChild = chk[i].getAttribute("CSI");
if (csiChild != null)
{
if(csiChild == mainchk)
{
if(chkMain.checked == true)
{
chk[i].checked = true;
}
else
{
chk[i].checked = false;
}
}
}
}
}
}
function CheckAllBidders(chkMain)
{
// debugger;
var mainCSI = chkMain.getAttribute("CSI");
var csi;
var csiChild;
var bidder;
var chkChildID;
var chk = document.documentElement.getElementsByTagName("input");
var i;
for(i=0;i<chk.length; i++)
{
if(chk[i].type=='checkbox')
{
// chkChildID = chk[i].id;
// s = chkChildID.indexOf(":");
csiChild = chk[i].getAttribute("CSI");
bidder = chk[i].getAttribute("Bidder");
if (csiChild != null && bidder != null)
{
if(csiChild==mainCSI)
{
// debugger;
if(chkMain.checked == true)
{
chk[i].checked = true;
}
else
{
chk[i].checked = false;
}
}
}
}
}
}
var btnReloadExpandedID = '<%=ButtonReloadExpanded.ClientID %>';
var hdnExpandBidderID = '<%=hdnExpandBidder.ClientID %>';
var btnBindBiddingStatus = '<%=ButtonBindBiddingStatus.ClientID %>';
var btnBindNotes = '<%=ButtonBindNotes.ClientID %>';
var hdnNoteCSI = '<%=hdnNoteCSI.ClientID %>';
var hdnCSIId1 = '<%=hdnCSIId1.ClientID %>';
var hdnExpandCSIs = '<%=hdnCSIIs.ClientID %>';
var NoteLabelID;
</script>
<script>
function BindNote(csivalue1,note)
{
// var ButtonBindNotes1 = document.getElementById(btnBindNotes);
// var HiddenNotesCSI1 = document.getElementById(hdnNoteCSI);
// HiddenNotesCSI1.value = csivalue1;
// ButtonBindNotes1.click();
document.getElementById(NoteLabelID).innerHTML = note;
SethdnUpdatedValues(NoteLabelID,note);
}
function SethdnUpdatedValues(id,value)
{
//debugger;
if (id!=undefined)
{
var hdnUpdatedValues = document.getElementById('<%=hdnUpdatedValues.ClientID %>');
if(hdnUpdatedValues.value!="")
if(hdnUpdatedValues.value.indexOf(id) !=-1)
{
var st = hdnUpdatedValues.value.indexOf(id);
var end = hdnUpdatedValues.value.indexOf("|~|",st);
var valToReplace = hdnUpdatedValues.value.substring(st,end);
var valReplaceBy = id + "=" + value;
hdnUpdatedValues.value = hdnUpdatedValues.value.replace(valToReplace, valReplaceBy);
}
else
hdnUpdatedValues.value = hdnUpdatedValues.value + id + '=' + value + '|~|';
else
hdnUpdatedValues.value = id + '=' + value + '|~|';
}
}
function SetUpdatedValues()
{
//debugger;
try
{
var hdnUpdatedValues = document.getElementById('<%=hdnUpdatedValues.ClientID %>');
if (hdnUpdatedValues.value != "")
{
var values = hdnUpdatedValues.value.split('|~|');
var ctrlValue;
var i;
for(i=0; i<values.length-1;i++)
{
ctrlValue = values[i].split('=');
document.getElementById(ctrlValue[0]).innerHTML = ctrlValue[1];
}
}
}
catch(ex)
{
}
}
</script>
</telerik:RadCodeBlock>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true">
<ProgressTemplate>
<div style="background-color: White; position: absolute; z-index: 10; left: expression((this.offsetParent.clientWidth/2)-(this.clientWidth/2)+this.offsetParent.scrollLeft);
top: expression((this.offsetParent.clientHeight/2)-(this.clientHeight/2)+this.offsetParent.scrollTop);">
<img src="../Images/LoadingIcon.gif" height="80" width="150" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePannel1" runat="server">
<ContentTemplate>
<%--<script type="text/javascript" language=javascript>
function ShowData()
{
var trValues = document.getElementById('<%=trRptrDivision.ClientID %>');
trValues.style.visibility="visible";
}
</script>--%>
<asp:HiddenField ID="hdnUpdatedValues" runat="server" />
<script language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
SetUpdatedValues();
}
</script>
<asp:Label ID="lblTestStatus" runat="server"></asp:Label>
<input type="button" id="ButtonReloadExpanded" runat="server" style="display: none;"
value="Reload Expanded" />
<input type="button" id="ButtonBindBiddingStatus" runat="server" style="display: none;"
value="Bind BiddingStatus" />
<input type="button" id="ButtonBindNotes" runat="server" style="display: none;" value="Bind Notes" />
<asp:HiddenField ID="hdnExpandBidder" runat="server" />
<asp:HiddenField ID="hdnNoteCSI" runat="server" />
<asp:HiddenField ID="hdnCSIId1" runat="server" />
<asp:HiddenField ID="hdnCSIIs" runat="server" />
<table border="1" cellpadding="0" cellspacing="0" style="background: skyblue; border-style: solid;
border-width: 1px; border-color: black;" width="100%" id="tblBiddersList">
<tr>
<td colspan="3">
<asp:Label ID="lblError" runat="server" Font-Size="8pt" ForeColor="Red" Font-Bold="True"
EnableViewState="False" Font-Names="Arial"></asp:Label>
</td>
</tr>
<asp:Repeater ID="rptdivision" runat="server" EnableViewState="true" OnItemDataBound="rptdivision_ItemDataBound">
<HeaderTemplate>
<tr>
<td class="MasterHeader">
<asp:Button ID="ButtonExpandCollapse" UseSubmitBehavior="false" runat="server" Text="Expand All" CssClass="button"
CommandName="ExpandCollapse" />
Divisions
</td>
<td class="MasterHeader">
Divisions Description
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #66cc99;">
<td>
<input type="checkbox" id="chkDivision" biddercount='<%#DataBinder.Eval(Container, "DataItem.countBidders")%>'
runat="server" onclick="javascript:SelectAll(this);" />
<%-- <asp:CheckBox ID="chkDivision" runat="server" onclick="javascript:SelectAll(this);" />--%>
<asp:ImageButton runat="server" ID="ImageButton1" CommandName="ExpandDivision" ImageUrl="~/Secure/Images/plus_big.gif" />
<asp:Label ID="lbDivisionName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.classifier_name")%>'></asp:Label>
<%-- <asp:HiddenField ID="hfcgroup" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.csigroup")%>' />--%>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.classifier_description")%>'></asp:Label>
</td>
</tr>
<tr class="trup" id="trRptrDivision" runat="server" style="background: white;">
<td>
<asp:Repeater ID="rptrBidPackage" runat="server" OnItemCommand="rptrBidPackage_ItemCommand">
<%--<HeaderTemplate>
<tr>
<td class="MasterHeader">
<asp:Button ID="ButtonExpandCollapse" runat="server" Text="Expand All" CssClass="button"
CommandName="ExpandCollapse" />
CSI Code
</td>
<td class="MasterHeader">
CSI Description
</td>
</tr>
</HeaderTemplate>--%>
<ItemTemplate>
<tr class="trup" style="margin: 0px 0px 0px 0px; height: 0%; display: none" id="trMaster"
runat="server">
<td class="tdupMaster">
<asp:ImageButton runat="server" ID="ImageColapseExpand" CommandName="Expand" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.CSIValue")%>'
ImageUrl="~/Secure/Images/plus_big.gif" />
<b>
<input type="checkbox" id="chkCodes" biddercount='<%#DataBinder.Eval(Container, "DataItem.countBidders")%>'
runat="server" onclick="javascript:SelectCodes(this);" />
<%-- <asp:CheckBox ID="chkCodes" runat="server" onclick="javascript:CheckCodes();" /> --%>
<asp:Label ID="LabelCSI" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.CSIValue")%>'></asp:Label>
</b>
</td>
<td class="tdupMaster">
<em>
<%#DataBinder.Eval(Container, "DataItem.CSIDesc")%>
</em>
</td>
</tr>
<tr class="trup" id="trRptrBidders" runat="server" style="background: white; display: none">
<td colspan="2">
<table border="1" width="100%" cellpadding="1" cellspacing="1" style="background: #eeeeee;">
<asp:Repeater ID="rptrBidders" runat="server" EnableViewState="true" OnItemDataBound="rptrBidders_ItemCreated">
<HeaderTemplate>
<tr style="background: #cccccc; color: #205f7d; font-weight: bold; font-size: x-small;"
class="DetailHeader">
<td class="DetailHeader" align="right">
<input type="checkbox" id="chkSelectAll" runat="server" onclick="javascript:CheckAllBidders(this);" />
</td>
<td class="DetailHeader">
Action
</td>
<td class="DetailHeader">
Company name
</td>
<td class="DetailHeader">
Contact
</td>
<td class="DetailHeader">
Phone
</td>
<td class="DetailHeader">
Fax
</td>
<td class="DetailHeader">
Email</td>
<td class="DetailHeader">
Will Bid</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="trup" runat="server" id="trBidder">
<td rowspan="2" style="width: 50px;" id="tdCheckBox" align="right">
<asp:Label runat="server" ID="lblIsReceived" Text="+" Font-Bold="true" Visible="false"></asp:Label>
<input type="checkbox" id="chkBidder" runat="server" />
<input type="hidden" runat="server" id="hdnFaxStatus" value='<%#DataBinder.Eval(Container, "DataItem.FaxStatus")%>' />
<input type="hidden" runat="server" id="hdnIsReceived" value='<%#DataBinder.Eval(Container, "DataItem.IsReceived")%>' />
</td>
<td rowspan="2" style="width: 0%;">
<img style="margin: 0px;" onclick="pw('<%#DataBinder.Eval(Container, "DataItem.BidpackageID")%>','<%#DataBinder.Eval(Container, "DataItem.SiteUserID")%>','<%#DataBinder.Eval(Container, "DataItem.FolderID")%>');"
src="Images/tool_preview.gif" alt="View"></img><img style="margin: 0px;" src="Images/BidPackage/tool_bidder_edit.gif"
alt="Edit Bidder Info" onclick="be('<%#DataBinder.Eval(Container, "DataItem.BidderID")%>','<%#DataBinder.Eval(Container, "DataItem.BidpackageID")%>','<%#DataBinder.Eval(Container, "DataItem.CSIs!2!CSI")%>')"></img><img
style="margin: 0px;" src="Images/BidPackage/tool_approve_f2.gif" alt="Will Bid"
onclick="pb(this,'<%#DataBinder.Eval(Container, "DataItem.FolderID")%>','WB','<%#DataBinder.Eval(Container, "DataItem.BidderID")%>','<%#DataBinder.Eval(Container, "DataItem.CsiID")%>');"></img><img
style="margin: 0px;" src="Images/BidPackage/tool_decline_f2.gif" alt="Will Not Bid"
onclick="pb(this,'<%#DataBinder.Eval(Container, "DataItem.FolderID")%>','NB','<%#DataBinder.Eval(Container, "DataItem.BidderID")%>','<%#DataBinder.Eval(Container, "DataItem.CsiID")%>');"></img><asp:CheckBox
ID="chkIsReceived" ToolTip="Admin IsReceived" runat="server" FolderID='<%#DataBinder.Eval(Container, "DataItem.FolderID")%>'
Checked='<%#DataBinder.Eval(Container, "DataItem.AdminIsReceived")%>' />
</td>
<td class="fn">
<input type="hidden" runat="server" id="hdnBidder" value='<%#DataBinder.Eval(Container, "DataItem.BidderID")%>' />
<input type="hidden" runat="server" id="hdnCsiID" value='<%#DataBinder.Eval(Container, "DataItem.CsiID")%>' />
<%#DataBinder.Eval(Container, "DataItem.Organization")%>
</td>
<td class="fn">
<%#DataBinder.Eval(Container, "DataItem.FullName")%>
</td>
<td class="fn">
<nobr>
<%#DataBinder.Eval(Container, "DataItem.Phone")%>
</nobr>
</td>
<td class="fn">
<nobr>
<%#DataBinder.Eval(Container, "DataItem.Fax")%>
</nobr>
</td>
<td class="fn">
<nobr>
<%#DataBinder.Eval(Container, "DataItem.EMail")%>
</nobr>
</td>
<td class="fn">
<asp:Label ID="lblWillBid" runat="server">
<%#DataBinder.Eval(Container, "DataItem.WillBid")%>
</asp:Label>
</td>
</tr>
<tr id="trBidderNote">
<td colspan="6" style="font-size: xx-small; background-color: #FEFEFE; padding: 0px;">
<span id="spanBidderNote" runat="server" class="Note">Note:</span> 
<input type="hidden" runat="server" id="hdnBidderNoteID" value='<%#DataBinder.Eval(Container, "DataItem.BidderNoteID")%>' />
<div style="height: 100%; width: 210px; border: solid 0px gray; display: inline;"
id="note">
<asp:Label ID="lblBidderNote" runat="server">
<%#DataBinder.Eval(Container, "DataItem.BidderNote")%>
</asp:Label>
</div>
   
<%#DataBinder.Eval(Container, "DataItem.Qualifications")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<%-- <asp:GridView ID="GridViewBidders" runat="server" EnableViewState="true" Visible="false">
</asp:GridView>--%>
</table>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ContentTemplate>
</asp:UpdatePanel>
your repeater is inside the update panel so use trigger of async type like follow:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="imagebtn" EventName="CLICK" />
</Triggers>
And make some changes in repeater's code...
<asp:ImageButton runat="server" ID="ImageColapseExpand" onclick="ImageColapseExpand_Click" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.CSIValue")%>'
ImageUrl="~/Secure/Images/plus_big.gif" />
<b>
Create a click event in code behind like bellow:
protected void ImageColapseExpand_Click(object sender, ImageClickEventArgs e)
{
}
Hope this will work for you......

how to validating unique entries of textbox on repeater control?

I have a repeater control rptbrand in which one textbox txtMultiBrand is there and after each repeating time when i click btnAddBrand button i want validation for unique entries in textbox, here is my aspx code
<table width="100%">
<asp:Repeater ID="rptBrand" runat="server" OnItemDataBound="rptBrandDetail_ItemDataBound">
<ItemTemplate>
<tr>
<td align="right" `enter code here`width="150">
Brand<asp:Label ID="lblBrandNum" runat="server"></asp:Label>
<span class="msgred">*</span> :
</td>
<td align="left">
<table width="100%">
<tr>
<td align="left" width="20%">
<asp:TextBox ID="txtMultiBrand" CssClass="imageSearch" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" ValidationGroup="VGrpMultiSave"
ControlToValidate="txtMultiBrand" ErrorMessage="Brand Required" Display="none"
SetFocusOnError="True"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ValidationGroup="VGrpSave"
ControlToValidate="txtMultiBrand" ErrorMessage="Brand Required" Display="none"
SetFocusOnError="True"></asp:RequiredFieldValidator>
</td>
<td align="left">
<asp:ImageButton ID="btnDelete" runat="server" CausesValidation="false" CommandName="CmdDelete"
CommandArgument='<%# Eval("SrNo") %>' ToolTip="Delete" ImageUrl="images/b_drop.png"
OnCommand="rptBrand_Command" Width="16" Height="16" OnClientClick="javascript:return confirm('Are you sure you want to remove brand?')" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td align="right" width="150">
</td>
<td>
<asp:Button ID="btnAddBrand" runat="server" Text="Add more" ValidationGroup="VGrpMultiSave"
OnClick="btnAddBrand_Click" />
<asp:ValidationSummary ID="ValidationSummary2" runat="server" DisplayMode="List"
ShowMessageBox="True" ShowSummary="False" ValidationGroup="VGrpMultiSave" />
</td>
</tr>
</table>
Using jQuery:
IT IS WORKING
Check the below link:
http://jsfiddle.net/NtF7h/
$(function () {
$("#<%=btnAddBrand.ClientID%>").on("click", function (event) {
var valueArray = new Array(); ;
$("input[id*='txtMultiBrand']").each(function (index) {
if ($.inArray($(this).val(), valueArray) == -1) {
valueArray[index] = $(this).val();
}
else {
alert("Duplicate Entry Found.");
event.preventDefault();
return false;
}
});
});
});

Problem with ajax and RadTreeView

Hi all :
I have a user control which contain RadTreeView from Telerik inside ModalPopupExtender , the previous control loaded at runtime :
DashBoardDesignerCell tempCell = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardDesignerCell.ascx") as DashBoardDesignerCell;
When SelectedNodeChanged occurs the ModalPopupExtender disappears.
This is the full code for user contrl:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="DashBoardDesignerCell.ascx.cs"
Inherits="RightBI.UserControls.DashBoardDesignerControls.DashBoardDesignerCell" %>
<%# Register Src="~/UserControls/PresentationControls/SelectPresentationControl.ascx" TagPrefix="rightbicontrols" TagName="selectpresentationcontrol" %>
<asp:UpdatePanel ID="dashboardDesignerCellUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table cellpadding="3" cellspacing="0" style='width: 100%; border-style: solid; border-width: thin;
border-color: Silver;'>
<thead>
<tr style='background: blue'>
<td>
<asp:ImageButton SkinID="selectControlButton" runat="server" ID="addControlButton"
OnClick="okButton_Click" />
<asp:ImageButton SkinID="deleteControlButton" runat="server" ID="removeControlButton"
OnClick="removeControlButton_Click" />
<asp:LinkButton runat="server" ID="LinkButton1" Style='display: none;'>
</asp:LinkButton>
<ajax:ModalPopupExtender runat="server" TargetControlID="addControlButton" ID="selectPresentationControlModalPopupExtender"
PopupControlID="popupSelectPresentationControl" CancelControlID="cancelButton"
BackgroundCssClass="popup_black_BG">
</ajax:ModalPopupExtender>
<asp:Panel runat="server" ID="popupSelectPresentationControl" Style='display: none;'>
<asp:UpdatePanel runat="server" ID="popupSelectUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<div class="popup_container">
<table cellpadding="0" cellspacing="0" class="popup_table">
<tr>
<td class="popup_header_left">
</td>
<td class="popup_header_middle">
</td>
<td class="popup_header_right">
</td>
</tr>
<tr>
<td class="popup_main_left">
</td>
<td class="popup_main">
<div class="popup_content">
<table cellpadding="0" cellspacing="0" style='width: 100%'>
<tr>
<td>
<span>Caption (*):</span>
</td>
<td>
<asp:TextBox runat="server" ID="captionTextBox">
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="captionTextBox"
ValidationGroup="SelectPresentationControl" ErrorMessage="Caption is required."
Text="*">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<rightbicontrols:selectpresentationcontrol id="selectControl" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<telerik:RadButton ID="okButton" Text="Save" SkinID="okButton" runat="server" CommandName="Save"
ValidationGroup="SelectPresentationControl" OnClick="okButton_Click">
</telerik:RadButton>
<telerik:RadButton ID="cancelButton" Text="Cancel" SkinID="cancelButton" runat="server"
CommandName="Cancel">
</telerik:RadButton>
</td>
</tr>
</table>
</div>
</td>
<td class="popup_main_right">
</td>
</tr>
<tr>
<td class="popup_footer_left">
</td>
<td class="popup_footer_middle">
</td>
<td class="popup_footer_right">
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</td>
</tr>
</thead>
<tbody>
<tr>
<td style='min-height: 150px;'>
<asp:UpdatePanel runat="server" ID="controlUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel runat="server" ID="controlPanel">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</tbody>
</table>
</ContentTemplate>
</asp:UpdatePanel>
public Guid DashboardColumnID
{
get
{
if (ViewState["DashboardColumnID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["DashboardColumnID"].ToString());
}
set
{
ViewState["DashboardColumnID"] = value;
}
}
protected Guid DashboardZoneID
{
get
{
if (ViewState["DashboardZoneID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["DashboardZoneID"].ToString());
}
set
{
ViewState["DashboardZoneID"] = value;
}
}
protected Guid PresentationControlID
{
get
{
if (ViewState["PresentationControlID"] == null)
{
return Guid.Empty;
}
return new Guid(ViewState["PresentationControlID"].ToString());
}
set
{
ViewState["PresentationControlID"] = value;
}
}
protected void LoadDashboardZone()
{
DashboardColumn dashboardColumn = DashboardColumn.GetDashboardColumn(DashboardColumnID);
if (dashboardColumn.DashboardZones.Count == 1)
{
DashboardZoneID = dashboardColumn.DashboardZones.FirstOrDefault().Id;
}
if (DashboardZoneID == Guid.Empty)
{
removeControlButton.Visible = false;
addControlButton.Visible = true;
}
else
{
removeControlButton.Visible = true;
addControlButton.Visible = false;
}
controlPanel.Controls.Clear();
if (DashboardZoneID != Guid.Empty)
{
DashboardDesignerZone zone = LoadControl("~/UserControls/DashBoardDesignerControls/DashboardZone.ascx") as DashboardDesignerZone;
zone.DashboardZoneID = DashboardZoneID;
controlPanel.Controls.Add(zone);
}
controlUpdatePanel.Update();
}
protected void Page_Load(Object sender, EventArgs e)
{
//
String code = "function openWindow() {var oWnd = $find('" + selectPresentationWindow .ClientID+ "');oWnd.show(); }";
ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "OpenRadWindow", code , true);
LoadDashboardZone();
}
protected void okButton_Click(object sender, EventArgs e)
{
AddPresentationControl(captionTextBox.Text, selectControl.PresentationControlId);
//dashboardDesignerCellUpdatePanel.Update();
}
protected void removeControlButton_Click(Object sender, EventArgs e)
{
if (DashboardZone.RemoveDashboardZone(this.DashboardZoneID))
{
PresentationControlID = Guid.Empty;
DashboardZoneID = Guid.Empty;
LoadDashboardZone();
//dashboardDesignerCellUpdatePanel.Update();
}
}
public void AddPresentationControl(String caption, Guid presentationControlID)
{
DashboardZone tempDashboardZone = DashboardZone.AddDashboardZone(caption, DashboardColumnID, presentationControlID);
if (tempDashboardZone != null)
{
PresentationControlID = presentationControlID;
DashboardZoneID = tempDashboardZone.Id;
LoadDashboardZone();
}
}
Is There any idea???
Do you by any means do postback or ajax request when a treeview node is selected? This might be potential cause the modal popup extender is closed. Why you do not use the Telerik Ajax window instead, to compare the results? Also I assume that you load the user control dynamically on init or load of the page and clear the Controls collection of the container before adding the user control inside it.

Resources