Solved

Adding jquery blocks __doPostback on aspx server generated objects

Posted on 2011-02-17
3
987 Views
Last Modified: 2012-05-11
Hi experts,

Hi have an aspx page with a repeater binded to a database:

<asp:Repeater runat="server" ID="repeaterMenu" DataSourceID="sdsApartats" OnItemDataBound="repeaterMenu_ItemDataBound" >
    <ItemTemplate>
        <tr id="trMenu">
            <td class="tdMenu">
                <asp:Panel ID="divMenu" runat="server" CssClass="menu" >
                    <asp:LinkButton ID="lbMenu" runat="server" CssClass="menu" OnClick="lbMenu_Command" CommandArgument=<%# Eval("idApartat") %>>
                        &nbsp; <%# Eval("titol").ToString().PadLeft(30,' ') %> &nbsp;
                    </asp:LinkButton>
                </asp:Panel>
            </td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

Open in new window


A bit forward I need a jquery animation so I add a jquery reference in the header:

<script src="Scripts/jquery-1.4.1.js" />

Open in new window


Only with this reference to jquery in the header, every time I run the application the page renders OK, but it raises an error:

Microsoft jscript runtime error: object expected

Open in new window


with debugger stopped at:

__doPostBack('ctl00$repeaterMenu$ctl00$lbMenu','')

Open in new window


I supose jquery gets somehow confused with the "$" separator in the sender's ID.
I've googled and even ee-ed and found no clue.

Can someone put a little light on this. An answer will be fully appreciated.
0
Comment
Question by:Catalaziz
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
BurnieP earned 250 total points
ID: 34921887
Hi,

You might have some conflict with another javascript library in your project.  You can try setting the noConflict to JQuery after your JQuery reference :

<script src="Scripts/jquery-1.4.1.js" />
<script type="text/javascript">
  $.noConflict();
</script>
0
 

Author Comment

by:Catalaziz
ID: 34924379
Thanks BurnieP,

There is no other library javascript library in this project.
You can easily repeat this behaviour by:

1. Create a new web site in Visual Studio .net framework 3.5.
2. In the default.aspx webform add a sqldatasource (or any other database binding object)
3. Add a repeater that generates a linkbutton for each record in the datasource object.
4. Link the command event handler of each linkbutton generated. Or use the itemcommand of the repeater; it makes no difference.
5. Add a reference to jquery in the head section of the aspx code.
6. Add a simple jquery animation at the document.ready jquery event.

That's all. Page renders OK but if you click on any of the generated buttons, you'll get the error.

Adding $.noConflict() gets postback running again, but any other jquery function (that simple animation at the document.ready event) stops working.

If I remove the asp:repeater, then the jquery code works fine, but I need those asp:repeater generated linkbuttons
0
 

Author Closing Comment

by:Catalaziz
ID: 34924396
Sorry for this section in my last comment:

"Adding $.noConflict() gets postback running again, but any other jquery function (that simple animation at the document.ready event) stops working."

The animation wasn't working because of a bug in the code of the animation.

You nailed it BurnieP!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WKHTMLTOPDF - --disable-smart-shrinking not working 10 35
Runtime Error 2 28
Data is not showing from images 15 37
Connection String 16 43
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now