I need to pass the calling element as "this" like I am doing for the calling element above. in addition to that I also i need to pass the next two elements as "this", is it possible to use jquery to pass the next two elements (ids called "secondcontrol"
and "thirdcontrol" in my code snippet) and if this is possible what is syntax to do this and what is the syntax to do this when passing the objects as a parameter to my javascript function? somethng like
This call passes a Jquery object reference to the other controls. You could also do this on all the controls: <input onclick="myJavascriptfunction(this);"/> The function could query the id to appy the needed logic;
function myJavascriptfunction(ctrl){
if(ctrl.id == 'firstcontrol')
dofirst();
else if (ctrl.id=='secondcontrol')
dosecond();
}
on the question about getting the next reference, on Jquey this is handle with the use of sibblings(). This however relies on how your html document is created. see this: http://api.jquery.com/siblings/
MyronCope
Participant
1656 Points
1345 Posts
pass "this" of next gridview itemtemplate
Nov 06, 2012 10:54 AM|LINK
using asp.net/vb.net 2010
lets say that I have a gridview that is like this
<asp:GridView ID="grdSearch" runat="server" AllowSorting="True" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="First" > <ItemTemplate> <input onclick="myJavascriptfunction(this);"/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Second" > <ItemTemplate> <input id="secondcontrol"/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Third" > <ItemTemplate> <label id="thirdcontrol"> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Fourth" > <ItemTemplate> <asp:CheckBox ID="chkFourth" runat="server" Enabled="false" Text='Fourth'></asp:CheckBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>I need to pass the calling element as "this" like I am doing for the calling element above. in addition to that I also i need to pass the next two elements as "this", is it possible to use jquery to pass the next two elements (ids called "secondcontrol" and "thirdcontrol" in my code snippet) and if this is possible what is syntax to do this and what is the syntax to do this when passing the objects as a parameter to my javascript function? somethng like
$this.next()
thanks
MC
ozkary
Contributor
2034 Points
303 Posts
Re: pass "this" of next gridview itemtemplate
Nov 06, 2012 01:37 PM|LINK
<input onclick="myJavascriptfunction(this, $('#secondcontrol'), $('#thirdcontrol') );"/>This call passes a Jquery object reference to the other controls. You could also do this on all the controls:
<input onclick="myJavascriptfunction(this);"/>
The function could query the id to appy the needed logic;
function myJavascriptfunction(ctrl){ if(ctrl.id == 'firstcontrol') dofirst(); else if (ctrl.id=='secondcontrol') dosecond(); }on the question about getting the next reference, on Jquey this is handle with the use of sibblings(). This however relies on how your html document is created. see this: http://api.jquery.com/siblings/
I hope this helps.
og-bit.com
asteranup
All-Star
30184 Points
4906 Posts
Re: pass "this" of next gridview itemtemplate
Nov 07, 2012 02:33 AM|LINK
Hi,
Try this code-
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog