1

I have the following in my code, which has worked fine in IE 7 and 8, but it no longer works in IE 9 (unless the user runs in compatibility mode of course...)

<asp:Label ID="invNumLink" runat="server" Font-Underline="true" ForeColor="Blue" Text='<%# Eval("Order_No") %>' createDate='<%# string.Format(Eval("create_date").ToString(),"MM/dd/yyyy") %>'
                                operatorNo='<%# Eval("operator_no") %>' orderNo='<%# Eval("Order_No") %>' loc='<%# Eval("Location") %>' table='<%# Eval("table_no") %>' recall='<%# Eval("recall_code") %>'
                                orderID='<%# Eval("ID") %>' acrID='<%# Eval("ACR_ID") %>'
                                onclick="goToDetail(this.orderNo,this.createDate, this.operatorNo, this.loc, this.table, this.recall, this.orderID, this.acrID);" style="cursor:pointer" ></asp:Label>

<script type="text/javascript">
    function goToDetail(orderNo, createDate, operatorNo, loc, table, recall, orderID, acrID) {
        var URL = 'OrderDetailView.aspx?orderNo=' + orderNo + '&' + 'createDate=' + createDate + '&' + 'operatorNo=' + operatorNo + '&' + 'loc=' + loc + '&' + 'table=' + 
                                        table + '&' + 'recall=' + recall + '&' + 'id=' + orderID + '&' + 'acrID=' + acrID;
        day = new Date();
        id = day.getTime();
        window.open(URL, id, 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=1100,height=700,left = 62,top = 15')
    }
</script>

In IE9 all of the values sent to the "goToDetail" function are undefined. Any ideas on how to fix this?

EDIT

I resolved this by adding the call to javascript from the code behind:

invNumLink.Attributes.Add("onclick", string.Format("goToDetail('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}'); return false;", item.GetDataKeyValue("Order_No").ToString(),
                string.Format(item.GetDataKeyValue("Create_Date").ToString(), "MM/dd/yyyy"),item.GetDataKeyValue("Operator_No").ToString(), item.GetDataKeyValue("Location").ToString(), 
                item.GetDataKeyValue("table_no").ToString(), item.GetDataKeyValue("recall_code").ToString(), item.GetDataKeyValue("ID").ToString(),item.GetDataKeyValue("ACR_ID").ToStrin

Thanks,

Aaron

5
  • Did you try move the javascript block before your <asp:label> tag? Commented Jul 11, 2011 at 16:14
  • That won't help - the problem is that IE9 won't hand over the attribute values for non-standard attributes like the older browsers would. Commented Jul 11, 2011 at 16:17
  • @Pointy--that's totally not cool.... :( Commented Jul 11, 2011 at 16:20
  • 1
    @Aaron: More like it being totally not cool that it's taken 9 versions for Microsoft to make a browser that even attempts to be standards-compliant. Commented Jul 11, 2011 at 16:26
  • 1
    @Marc: But I'm so used to it! :( Commented Jul 11, 2011 at 16:30

3 Answers 3

3

You could use data-attributes, which work like this:

Instead of:

<span operatorNo="value">

You use

<span data-operatorNo="value">

And access it with

this.getAttribute("data-operatorNo")

This works in IE6 and is documented as working in IE7+. Do HTML5 custom data attributes “work” in IE 6?

Sign up to request clarification or add additional context in comments.

Comments

1

I know this is UGLY... but maybe passing in the values directly would solve your issue.

<asp:Label ID="invNumLink" runat="server" Font-Underline="true" ForeColor="Blue" Text='<%# Eval("Order_No") %>' createDate='<%# string.Format(Eval("create_date").ToString(),"MM/dd/yyyy") %>'
                                operatorNo='<%# Eval("operator_no") %>' orderNo='<%# Eval("Order_No") %>' loc='<%# Eval("Location") %>' table='<%# Eval("table_no") %>' recall='<%# Eval("recall_code") %>'
                                orderID='<%# Eval("ID") %>' acrID='<%# Eval("ACR_ID") %>'
                                onclick="goToDetail('<%# Eval("Order_No") %>','<%# string.Format(Eval("create_date").ToString(),"MM/dd/yyyy") %>', '<%# Eval("operator_no") %>', '<%# Eval("Location") %>', '<%# Eval("table_no") %>','<%# Eval("recall_code") %>', '<%# Eval("ID") %>', '<%# Eval("ACR_ID") %>');" style="cursor:pointer" ></asp:Label>

1 Comment

Won't work with the double quotes inside of the Eval statement, which I now remember is why I did it the way I did it before. I think I'm going to have to add a style in the code behind...
1

For non-standard attributes on an HTML tag, I believe you need to use element.getAttribute("attName") to fetch non-standard attributes defined in the HTML rather than directly access them with element.attName. To stay with standards, you should also prefix custom data attributes with "data-".

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.