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

telerik UniqueID returns name?

3 Answers 98 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
dexter
Top achievements
Rank 1
dexter asked on 06 Mar 2012, 08:54 AM
Hi,

I'm trying to get the checkbox reference which is inside the grid using the property UniqueName.
It returns me this ctl01$ctl03$chk which is actually the name of the control rather than the id.

I noticed that the id is exactly the same, just that the $ symbol is replaced with _
which means the id is ctl01_ctl03_chk

I just need some confirmation that the only difference with name and id is the symbol $ and _
because i replaced the symbol $ with _ in order to get the reference of the checkbox.

Is this advisable? I'm just concern that in future telerik might use some kind of other symbols that might
render my code useless. Please help.
 
Regards,
Dexter

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Mar 2012, 02:35 PM
Hello dexter,

Can you please provide your aspx page code?

Thanks,
Jayesh Goyani
0
dexter
Top achievements
Rank 1
answered on 07 Mar 2012, 02:49 AM
Hi Jayesh,

There is nothing unusual about the aspx page. Just a normal grid with GridTemplateColumn having checkbox column inside it.

Here is the code behind:

string id = "";//global
protected void grdDmnDocFolder_ItemCreated(object sender, GridItemEventArgs e)
    {
      if (e.Item is GridDataItem)//will only be true if the object is item
      {
        GridDataItem item = (GridDataItem)e.Item;
  
 //need to replace $ with _ because $ is for name _ for id
//Eg:name = ctl01$ctl03$chk id = ctl01_ctl03_chk
        id += item["chk"].FindControl("chkI").UniqueID.Replace('$', '_') + ",";
        ajxManager.ResponseScripts.Add("id = '" + id + "';");
          
    }
  
protected void grdDmnDocFolder_ItemDataBound(object sender, GridItemEventArgs e)
{
      if (e.Item is GridHeaderItem)//will only be true if the object is header
      {
        GridHeaderItem headerItem = (GridHeaderItem)grdDmnDocFolder.MasterTableView.GetItems(GridItemType.Header)[0];
        CheckBox chk = (CheckBox)headerItem.FindControl("chkH");
        ajxManager.ResponseScripts.Add("hdrID ='" + chk.UniqueID.Replace('$','_') + "';");
      }
}


Regards,
Dexter
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 08 Mar 2012, 07:17 AM
Hello Dexter,

CheckBox chk = (CheckBox)headerItem.FindControl("chkH");
                chk.ClientID // try to access with this clientId


Thanks,
Jayesh Goyani
Tags
General Discussions
Asked by
dexter
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
dexter
Top achievements
Rank 1
Share this question
or