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

Convert C# code to JavaScript

2 Answers 850 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hassan
Top achievements
Rank 1
Hassan asked on 12 Apr 2013, 02:13 PM
Hello,
I've written the code below in c# and i want to convert it to JavaScript
Because i need it in Client-side
is there anyone to convert it for me?

this is my C# code :
int res = 1;
       
       for (int i = 0; i < 15; i++)
       {
           int row = 0;
           if (((Telerik.Web.UI.RadButton)GridView1.Rows[i].FindControl("btn_1")).Checked != true)
           {
               row += 1;
           }
 
           if (((Telerik.Web.UI.RadButton)GridView1.Rows[i].FindControl("btn_2")).Checked != true)
           {
              row += 1;
           }
 
           if (((Telerik.Web.UI.RadButton)GridView1.Rows[i].FindControl("btn_3")).Checked != true)
           {              
               row += 1;
           }
           if (row == 0)
               row = 1;
           res = res * row;
       }

Thank you
Hassan

2 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 16 Apr 2013, 01:02 PM
Hi Hassan,

You can find the RadGrid's instance on the client through jQuery's $find() method. Then you can use the following client-side methods:
  • get_masterTableView() in order to get access to the MasterTableView of the RadGird
  • get_dataItems() in order to iterate through the rows (items) in the MasterTableView
  • $telerik.findControl() along with get_cell() in order to find the certain control from the particular cell of the row.
I have also attached a VS example to this post that demonstrated how to do that. It consists of a databound RadGrid to a datasource with four rows. The RadGrid has a GridTemplateColumn that consists of three RadButtons (type="ToggleButton"), one RadTextBox and another RadButton (type="StandardButton"). When you click the standardbutton a JavaScript function is triggerered OnClientClicked event, so that it iterates through the toggle buttons and stores the number of the checked ones in the RadTextBox.

You can also find useful this, this and this online resource.

Regards,
Danail Vasilev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hassan
Top achievements
Rank 1
answered on 11 May 2013, 09:38 PM
Thank you Danail :)
Tags
General Discussions
Asked by
Hassan
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Hassan
Top achievements
Rank 1
Share this question
or