in Education by
I have the following repeater control, which is bound to collection of DashboardPage objects. DashboardPage has the following properties: Name, Pagenumber . " onmouseover="<%# GetMouseOverEventString(Container.DataItem) %>" onmouseout="<%# GetMouseOutEventString(Container.DataItem) %>" />    I want to bind ImageButton's ID property to Name property of DashboardPage object, something like this ID="<%# Eval('Name') %>" But an exception is thrown: The ID property of a control can only be set using the ID attribute in the tag and a simple value. I need the ID property of the image, because I have a client side script which changes the image, using the it's ID. Is there a way around this? Thanks for replies Regards Gagik Kyurkchyan JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Since you have found you cannot dynamically set the ID of a server control you need to find an alternative way of referencing your image using JavaScript. There are three ways I can think of: Set the CssClass property of the control and use that instead. It's a little more inefficient to find a control by class rather than ID using DOM, but that is probably negligible in the real world. Wrap your image in a standard DIV. and set the ID on the container DIV. You can then use something like jQuery to go $("#divid img")... Use a standard image tag (with no runat="server") rather than an asp:Image control. You can then set the ID on that without issue.

Related questions

0 votes
    I am trying to bind the value of a property (MyTitle) of a class (MainWindow) that derives from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    This question already has an answer here: Object.assign getters and setters in constructor (1 answer) Closed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    This question already has an answer here: Object.assign getters and setters in constructor (1 answer) Closed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I have a basic form with controls that are databound to an object implementing the INotifyPropertyChanged interface. ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I think the direct answer to the question is 'No' but I'm hoping that someone has written a real ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Which property in the Window object is used to refer to a Location object? (a) position (b) area ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which of the following object belongs to the style property? (a) Element (b) Window (c) Location ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    The URL property belongs to which of the following object? (a) Document (b) Element (c) Location ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which among the following is not a property of the Location object? (a) protocol (b) host (c) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    The navigator property belongs to which of the following object? (a) Document (b) Window (c) Navigator ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    What is the purpose of the Node object property ownerDocument? (a) Returns the root element (b) Returns ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Which of the following Node object property returns the local part of the name of a node? (a) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
...