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

Passing values from server side to javascript

2 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
staron
Top achievements
Rank 1
staron asked on 31 Mar 2009, 08:41 AM
Hi,
is there any way to pass values from server side to javascript with the grid? Eg. I have a grid using clientside binding and I need to pass the editpanel id to js.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 31 Mar 2009, 09:56 AM
Hi Staron,

Try the following code snippet to pass value from server side to the client side. Here I am passing the Edit form table ID to the Client click event of the update button.

CS:
 
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditFormItem editform = (GridEditFormItem)e.Item; 
            Table editTable = (Table)editform.FindControl("mainTable"); 
            LinkButton lnkbtn = (LinkButton)editform.FindControl("UpdateButton"); 
            lnkbtn.Attributes.Add("OnClick""Show('" + editTable.ID + "');"); 
        } 
        
    } 


JS:
 
<script type="text/javascript" > 
  function Show(EditFormID) 
  { 
   alert(EditFormID) 
  } 
 
</script> 


Thanks
Shinu.
0
staron
Top achievements
Rank 1
answered on 31 Mar 2009, 10:10 AM
Thank you for your reply, but sadly I don't think your suggestion will work in my scenario as it relies on postbacks. What I need is to be able to get attributes in js. Say that I have added an attribute like this: RadGrid1.Attributes.Add("test", "test"). Now I need to access this in js. Is that possible?
Tags
Grid
Asked by
staron
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
staron
Top achievements
Rank 1
Share this question
or