29288

search for ClientID client-side or server-side?

Question:

I understand that I currently can't use <a onclick="alert('<%=TextBox1.ClientID%>')" directly because I need to access it in a table cell in a table in the EditTemplate of a DataList inside a UserControl.

That said, I need to recursively check the controls to get the ClientID, should it be done<br /><strong>client-side</strong>: alert(getMyElement('TextBox1').id), where getMyElement checks all elements of the form and returns the control with the id...or<br /><strong>server-side</strong>: alert('<%=FindElement(dlDataList, "TextBox1").ClientID%>') where FindElement is a base page function that checks the controls of the first param for an element with an id of the second param and returns that control ?

I'm figuring the client-side would be faster?

Answer1:

I always go with server side for this case. Otherwise you're traversing the entire DOM with each row - depending on the size, it could be a memory hog. Server side takes almost no resources for this.

Recommend

  • Using VisualStateManager to start and stop Storyboards
  • WPF MVVM WinformsHost with OpenGL-Control
  • R Tree With n Branches
  • Watching for file changes within a directory [duplicate]
  • Receive mouse move even cursor is outside control
  • How can I tell a form not to dispose a particular control when it closes?
  • WPF version of .ScaleControl?
  • Pycharm: Marking a folder as 'sources root' is not recursive for subfolders
  • Overlapping controls in Windows XP
  • Ember.js model to be organised as a tree structure
  • IE7 and TinyMCE with Plone
  • Eloquent paginate function in Slim 3 project using twig
  • How can I set a binding to a Combox in a UserControl?
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • Retrieve list of sent friend requests from friend_request FQL table
  • java inputstream
  • Jackson Parser: ignore deserializing for type mismatch
  • D3 nodes and links from JSON with nested arrays of children
  • OpenGL ES texture problem, 4 duplicate columns and horizontal lines (Android)
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Can I check if a recipient has an automatic reply before I send an email?
  • Handling un-mapped Rest path
  • Recording logins for password protected directories
  • Using jQuery closest() method with class selector
  • Splitting given String into two variables - php
  • Regex thinks I'm nesting, but I'm not
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Check if a string to interpolate provides expected placeholders
  • Fill an image in a square container while keeping aspect ratio
  • When should I choose bucket sort over other sorting algorithms?
  • jQuery tmpl and DataLink beta
  • How can I estimate amount of memory left with calling System.gc()?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Unanticipated behavior
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • SQL merge duplicate rows and join values that are different
  • Proper way to use connect-multiparty with express.js?
  • How to set the response of a form post action to a iframe source?
  • Reading document lines to the user (python)