Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding jquery blocks __doPostback on aspx server generated objects

Posted on 2011-02-17
3
Medium Priority
?
1,022 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 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview

772 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