Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Javascript
Hi,
 
I am fairly new to ASP .Net and I encountered an issue where after I fire my dropdownlist onchange JavaScript, my linkbutton is no longer doing its server side code. I am wondering what happened because my Submit button is working except for the link button. I have tried changing it to a Button but it is still not working.
 
The link button is tasked to add another row in the gridview.
 
Thanks for the help.
 
Jim
Posted 26-Feb-12 16:27pm
JimAce393
Comments
Varun Sareen at 26-Feb-12 23:01pm
   
Please post some code
SAKryukov at 26-Feb-12 23:11pm
   
"No longer doing its server side code" is not informative. How about code sample and proper explanation of the problem?
--SA
JimAce at 27-Feb-12 19:50pm
   
Heres the code..
 
The grid view is inside the update panel...
 
The grid view contains the following
1. Remove Line
2. Add Line to grid
 
The issue is... I have the ID dropdown1 included with the OTHER option. When Other is selected a JavaScript will show and prompt will ask for an input. Everything works well but after this action any button inside the grid view is no longer working... which means the Add row(lnkbtnAddNewRow) and remove row(lnkbtnRemoveRow) no longer fires. I am stuck.
 
I tried another approach by removing it from the update panel. Everything works well including the OTHER button but once I hit the Add Row or Remove Row it returns a long exception about required validator.
 
Help...
 
Thank you.
 
================
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script language="javascript" type="text/javascript">
function BtnOnClick_Submit() {
if (Page_ClientValidate('vgSubmitForm')) {
return confirm("Are you sure you want submit this form?");
}
else {
alert("Marked in red asterisks (*) are required. \nOtherwise, please 'Remove' the entry.");
}
}
function promptDesignation(select) {
if (select.value != "Other") return;
var answer = prompt("Please enter new designation", "");
if (!answer) {
select.selectedIndex = select.options.length - 13;
return;
}
var newOption = document.createElement("option");
newOption.text = answer;
newOption.value = answer;
select.insertBefore(newOption, select.lastChild);
select.selectedIndex = select.options.length - 1;
 
}
</script><pre lang="xml"><link href="/css/ceapstylesheet.css" rel="stylesheet" type="text/css" />
 
<div style="margin: 0 auto; width:850px;">
<div style="text-align: left"><br />
<h5 align="center">FORM</h5><br /><br />
<p><h3>Registration No. <asp:Label ID="lblRegNo" runat="server" /></h3></p>
<hr />
<table class="con-reg">
<tr>
<th width="12%">Region</th>
<td width="88%"><b>: <asp:Label ID="lblRegion" runat="server" /></b></td>
</tr>
<tr>
<th>Name of School</th>
<td><b>: <asp:Label ID="lblNameOfSchool" runat="server" /></b></td>
</tr>
<tr>
<th>Arch</th>
<td><b>:
<asp:Label ID="lblDiocese" runat="server" />
</b></td>
</tr>
<tr>
<th>Address</th>
<td><b>: <asp:Label ID="lblAddress" runat="server" /></b></td>
</tr>
</table>
<hr />
<h2>Attendees</h2>
<br />
<ul><strong style="color:#ff0000;">Note:</strong>
<li style="list-style-position:inside;">You can change the name of the students even after registering.</li>
<li style="list-style-position:inside;"><b>Five (5) minute walk</b> between Venue.</li>
</ul>
<br />
<asp:UpdatePanel ID="upAttendees" runat="server" Visible="true">
<ContentTemplate>
<asp:Gridview ID="Gridview1" runat="server" ShowFooter="true" GridLines="None"
Au
Tejas_Vaishnav at 27-Feb-12 23:26pm
   
while calling your javascript function at the end of your function based on your logic you need to return true or false, if your function return true means it will valid so it will go for server side scripting or if it will return false then it will not go for serve side scripting...
 
make this changes and test it will work or not...
JimAce at 27-Feb-12 23:32pm
   
Thanks I will check
Tejas_Vaishnav at 27-Feb-12 23:28pm
   
and also one more thing while you provide your code at that time not copy paste whole page code in side this questions but make some sense to paste necessary code.. and also provide some comment where or on which line you face any error...
JimAce at 27-Feb-12 23:48pm
   
This the line for my dropdownlist
<asp:DropDownList ID="dropdown1" AutoPostBack="false" onchange="promptDesignation(this)" runat="server" Width="250px" > - the onchange works as it calls javascript
 
These are the functions not working inside the update template after I fire the javascript (after selecting "Other" from dropdown1)
 
1 Remove:
<asp:LinkButton ID="lnkbtnRemoveRow" runat="server" Font-Size="10px" OnClick="lnkbtnRemoveRow_Click">Remove
 
2 Add Row:
<asp:LinkButton ID="lnkbtnAddNewRow" runat="server" Text="Add Another Attendee" Font-Size="11px" OnClick="lnkbtnAddNewRow_Click"/>
 
Does update panel has something to do with it?
 
Thanks for the help.
 
Let me know if this helps. Thanks a lot.
+++++++++++++++++++++++++++++++++++++++++++++++++++
Here's the code. I removed the elements not needed.
 

Attendees

<br />
<asp:UpdatePanel ID="upAttendees" runat="server" Visible="true">

<asp:Gridview ID="Gridview1" runat="server" ShowFooter="true" GridLines="None"
AutoGenerateColumns="false" OnRowCreated="Gridview1_RowCreated"
BorderStyle="None" Width="100%" >

<asp:BoundField DataField="RowNumber" HeaderText=" " ItemStyle-VerticalAlign="Top" ItemStyle-Font-Bold="true" ItemStyle-Font-Size="Large" ItemStyle-ForeColor="#3687D6" />
<asp:TemplateField ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top">

<table class="con-attendee">
<tr>
<th width="50%">Designation:</th>
</tr>
<tr>
<td>
<asp:DropDownList ID="dropdown1" AutoPostBack="false" onchange="promptDesignation(this)" runat="server" Width="250px" >
<asp:ListItem Text=" - Select Position - " Value=""/>
<asp:ListItem Text="Position1" Value="Position1"/>
<asp:ListItem Text="Other" Value="Other"/>

</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>


<asp:LinkButton ID="lnkbtnAddNewRow" runat="server" Text="Add Another Attendee" Font-Size="11px" OnClick="lnkbtnAddNewRow_Click"/>


<asp:TemplateField>

<asp:LinkButton ID="lnkbtnRemoveRow" runat="server" Font-Size="10px" OnClick="lnkbtnRemoveRow_Click">Remove




<div style="margin: 10px 0;">
<asp:UpdateProgress ID="uprogAttendees" runat="server" AssociatedUpdatePanelID="upAttendees">
<ProgressTemplate>
</span>
</ProgressTemplate>

</div>
 
<div class="con-sign">
<asp:Button ID="btnSubmitForm" runat="server" Text="Submit" Font-Bold="true" ForeColor="White" BorderColor="#0167CB" BackColor="#3687D6" ValidationGroup="vgSubmitForm" OnClientClick="return BtnOnClick_Submit();" Width="100px" OnClick="btnSubmit_Click" /></p>
</div>
</div>


<br /><br />


</div>
</div>
</div>
</form>
</body>
</html
Dean Oliver at 28-Feb-12 8:56am
   
Please post your code in the question not as a comment and reference the line in which the problem is ocuring. thanks.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Not Working
  Permalink  
Comments
Nelek at 9-Nov-12 3:54am
   
???????????

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 289
1 DamithSL 225
2 OriginalGriff 175
3 Peter Leow 150
4 Afzaal Ahmad Zeeshan 95
0 OriginalGriff 7,355
1 DamithSL 5,254
2 Sergey Alexandrovich Kryukov 4,942
3 Maciej Los 4,906
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100