Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Comments
Varun Sareen 26-Feb-12 23:01pm    
Please post some code
Sergey Alexandrovich Kryukov 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 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 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 27-Feb-12 23:32pm    
Thanks I will check

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900