0

for some reason only the asp.net hyperlink is not workin with jquery. Any suggestions?

<asp:HyperLink runat="server" ID="hypeDeleteBaseline" Text="Delete Baseline" /> <br/>

//Delete Baseline information
jQuery('[id$="hypeDeleteBaseline"]').click(function (e) {
    e.preventDefault();      
    var equipid = "<%=Equipment.ID%>";
    var inspectionid = jQuery('[id$="ddInspectionDate"]').val();
    deleteBaseline(equipid, inspectionid);
});

Thanks for any help.

0

3 Answers 3

1

Your selector is a little unusual. Have you tried:

jQuery('#hypeDeleteBaseline').click(...)

Also, have you checked the HTML that gets rendered? As often as not, the ID that you set on the control is not actually the ID that gets rendered in the HTML. Something like this might work:

jQuery('<%=hypeDeleteBaseline.ClientId%>').click(...)

Finally, you didn't include much context with your javascript class. Make sure it's inside a document-ready handler:

<script type="text/javascript">
    jQuery(function(){
        //Delete Baseline information
        //...
    });
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

You need to get the ClientId as rendered on html and not as parametre, try:

jQuery('#<%=hypeDeleteBaseline.ClientID%>')

or if you working with Net 4, set ClientIDMode="Static" on your HyperLink to not change the render id.

Comments

0

Nothing was wrong with my code. The asp hyperlink was being loaded via jquery.load ajax call. so on the call back function for load i just added

jQuery('[id$="hypeDeleteBaseline"]').click(function (e) {
        e.preventDefault();      
        var equipid = "<%=Equipment.ID%>";
        var inspectionid = jQuery('[id$="ddInspectionDate"]').val();
        deleteBaseline(equipid, inspectionid);
    });

And now it works perfectly. Thanks for all suggestions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.