Click here to Skip to main content
15,125,074 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all, I am showing an alert message from code behind using ScriptManager.RegisterClientScript .Initially its working as it should be but when i used a ajax control toolkit on the page its not working and showing a syntax error enexpected identifier ....

here i attached my code ...

HTML PAGE SOURCE ....

XML
<%--Balloon Popup--%>
                                                               <asp:BalloonPopupExtender
                                                                   ID="BalloonPopupExtender1"
                                                                   runat="server"
                                                                   BalloonPopupControlID="pnlBalloonPopup"
                                                                   TargetControlID="coapplicantsTD"
                                                                   Position="TopRight"
                                                                   BalloonStyle="Rectangle">
                                                               </asp:BalloonPopupExtender>

                                                               <td class="coapplicants" runat="server" id="coapplicantsTD">
                                                                   <asp:Panel runat="server" style="display:none;" ID="pnlBalloonPopup" CssClass="pnlballoon">
                                                                   <table border="1" style="width: 100%; border-collapse: collapse;">
                                                                       <tr runat="server"  id="noitems" >
                                                                           <td colspan="4" style="font-size:15px;">
                                                                               No Co-Applicants added.
                                                                           </td>
                                                                       </tr>
                                                                       <asp:Repeater runat="server" ID="rptCoapplicants">
                                                                           <HeaderTemplate>
                                                                               <tr>
                                                                                   <td>Sl. No.</td>
                                                                                   <td>Co-Applicant Name</td>
                                                                                   <td>Co-Applicant Father's Name</td>
                                                                                   <td>Co-Applicant's Voter Id</td>
                                                                               </tr>
                                                                           </HeaderTemplate>
                                                                           <ItemTemplate>
                                                                               <tr>
                                                                                   <td><span><%#Eval("SerialNo") %></span></td>
                                                                                   <td><span><%#Eval("CoApplicantName") %></span></td>
                                                                                   <td><span><%#Eval("CoApplicantFatherName") %></span></td>
                                                                                   <td><span><%#Eval("CoApplicantVoterId") %></span></td>
                                                                               </tr>
                                                                           </ItemTemplate>
                                                                       </asp:Repeater>
                                                                   </table>
                                                               </asp:Panel>
                                                                   <span>Click To Show</span></td>

                                                               <%--End--%>


Code Behind

C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "errormsg", "alert('CLUSTER FROM A SINGLE GP AT A TIME !!!!')", true);
Posted
Updated 19-Feb-15 21:43pm

Can't see the Ajax script manager on page, for Ajax to work in asp.net, you should have Script manager registered. For more info:
https://msdn.microsoft.com/en-us/magazine/cc163354.aspx[^]
   
Comments
kumar nitesh 20-Feb-15 4:59am
   
yes i have added ajax scriptmanager in master page and ajax control is working perfectly .but the client script in not working .throwing a javascript error unexpected identifier
SaranshSrivastava 22-Feb-15 12:10pm
   
Ok. Then try this:

ScriptManager.RegisterStartupScript(this, GetType(), "errormsg","alert('my message');", true);

I think semi colon is missing in your JS function.
Change your code...
C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "errormsg", "alert('CLUSTER FROM A SINGLE GP AT A TIME !!!!')", true);

to...
C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "errormsg", "alert('CLUSTER FROM A SINGLE GP AT A TIME !!!!');", true);

Just a semicolon and you are good.

This is because the code which will follow this line when rendered won't work because this line is invalid due to the missing semicolon.

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