This is a migrated thread and some comments may be shown as answers.

Find control client of link controls in commanditemsettings

5 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zash
Top achievements
Rank 1
Zash asked on 13 Apr 2011, 08:49 PM
I have link buttons at

 

 

 

 

<CommandItemTemplate>

 

 

 

 

 

 

 

 

<table width="35%">

 

 

 

 

 

 

 

 

<tr>

 

 

 

 

 

 

 

 

<td><asp:LinkButton ID="ButtonEditAll" runat="server" Text="Edit All"

 

 

 

CommandName="EditAll" /></td>

 

 

 

 

 

 

 

 

<td><asp:LinkButton ID="ButtonUpdateAll" runat="server" Text="Update All"

 

 

 

CommandName="UpdateAll" /></td>

 

 

 

 

 

 

 

 

<td>

 

 

 

 

 

 

 

 

<asp:LinkButton ID="DownloadPDF" runat="server" Text="Download"

 

 

 

CommandName="ExportToPdf" /></td>

 

 

 

 

 

 

 

 

</tr>

 

 

 

 

 

 

 

 

</table>

 

 

 

 

 

 

 

 

</CommandItemTemplate>

 

 

 

 

and I waht to check spelling after clicking this button. But I don't know how to get these buttons client ids.  Please give me a help.

Thanks

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Apr 2011, 06:29 AM
Hello Zash,
I am not quite sure about the requirement and I suppose you want to execute some client side code when clicking the LinkButtons. If that is the case you can directly attach the client side event and write the code there.
aspx:
<td>
  <asp:LinkButton ID="ButtonEditAll" OnClientClick="CheckSpelling();" runat="server" Text="Edit All" CommandName="EditAll" />
</td>
Javascript:
function CheckSpelling()
   {
  //your code here
   }

If this is not your case, please elaborate the scenario.

Thanks,
Shinu
0
Zash
Top achievements
Rank 1
answered on 14 Apr 2011, 11:07 PM
Yes, we want to execute client code after completing spelling check by RadSpell, and we need to know control client id.  The problem is our link button is in <CommandItemTemplate> of RadGrid, we need to know how to find link button client at server code.  When spelling check comptetes, RadSpell fires  OnClientCheckFinished, then it will execute java script to fire this link button "click" event.  Since this link button is in a template, I need to which event in grid generate this control and I can find its client id.

Thanks
0
Shinu
Top achievements
Rank 2
answered on 18 Apr 2011, 02:02 PM
Hello Zash,

If you want to get the LinkButton from client side, try the following code snippet.

ASPX:
<CommandItemTemplate>
        <asp:LinkButton ID="ButtonEditAll" runat="server" Text="Edit All" CommandName="EditAll" />
        <asp:LinkButton ID="ButtonUpdateAll" runat="server" Text="Update All" CommandName="UpdateAll" />
 </CommandItemTemplate>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridCommandItem)
       {
           GridCommandItem cmdItem = (GridCommandItem)e.Item;
           LinkButton editbtn = (LinkButton)cmdItem.FindControl("ButtonEditAll");
           LinkButton updatebtn = (LinkButton)cmdItem.FindControl("ButtonUpdateAll");
           editbtn.Attributes.Add("onclick", "CheckSpelling(this,'" + updatebtn.ClientID + "');");
       }
   }

Java Script:
<script type="text/javascript">
    function CheckSpelling(editbtn, updatebtn) {
        var updatebutton = document.getElementById(updatebtn);//accessing Update LinkButton
    }
</script>

Hope this helps,
-Shinu.
0
Zash
Top achievements
Rank 1
answered on 19 Apr 2011, 03:29 PM
I have a grid in web page.  At that grid, I add an "edit all" button at command template.  When user clicks it, all rows at that grid will be in edit mode.  And another "update all" will update all user's change and update data into database.  That works fine.  Problem comes when I try to add spelling check function to it.

I add spelling check to "update all" and it works, and speeling check "update" button at a grid row and it works fine too.  But when user clicks "edit all" button, all rows in edit mode. "Hidden" controls  are needed for each row to hold "update" button client id, and radajaxmanager needs to add <ajaxsettings> dynamically too.  I want to check with you the way I try to code is right, and please provide me some sample code to accomplish it.

Thanks
0
Mira
Telerik team
answered on 25 Apr 2011, 12:27 PM
Hello Zash,

I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this message.

I hope it helps.

Kind regards,
Mira
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Zash
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Zash
Top achievements
Rank 1
Mira
Telerik team
Share this question
or