I need to add onclick method to textbox inside grid.In this scenerio i can bind the client id the get the value of that grid item inside javascript method or can bind directly the value to the javascript method which is the best way for implementation
1. binding the client id and getting the value
txtbx1.attributes.add("onclick","Getvalues('txtbx1')");
2. Bind value directly to the method
txtbx1.attributes.add("onclick","Getvalues('20')");
Loading


Jignesh TrivediRank #16 · 50.3K reputationPosted May 19, 2014, 11:12 PM EDT
Ideally both are same in 1st case probably you send whole object of textbox (may be using txtbx1.attributes.add("onclick","Getvalues(this)"); ) and 2nd one you send the value of text box.
Anupam SinghRank #643 · 3.7K reputationPosted May 19, 2014, 10:55 PM EDT
But i dont think it should work like this..
because your GetValues(Type t) method might take int type of parameter.
you should use GetValues(Convert.ToInt32(txtbx1.Text)).
Yadlapalli SrikanthRank #7,940 · 231 reputationPosted May 19, 2014, 10:59 PM EDT
in case of the column is editable i can use the first one but it is not editable.It is a constant so i can pass the value directly.can you explain why the first one is best
Anupam SinghRank #643 · 3.7K reputationPosted May 19, 2014, 11:01 PM EDT
because there should not be hard-coded value in method parameter.
Yadlapalli SrikanthRank #7,940 · 231 reputationPosted May 19, 2014, 11:04 PM EDT
Anupam SinghRank #643 · 3.7K reputationPosted May 19, 2014, 11:07 PM EDT
Yadlapalli SrikanthRank #7,940 · 231 reputationPosted May 19, 2014, 11:23 PM EDT
Yadlapalli SrikanthRank #7,940 · 231 reputationPosted May 19, 2014, 11:51 PM EDT
Akhil MittalRank #133 · 16.9K reputationPosted May 20, 2014, 12:31 AM EDT
Nilesh AvhadRank #3,587 · 406 reputationPosted May 20, 2014, 1:40 AM EDT
I will prefer 1st one.
Thanks,
Nilesh