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

ClientScript.RegisterStartupScript not firing in ItemDataBound of popup of RadGrid

6 Answers 1983 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajz
Top achievements
Rank 1
Rajz asked on 26 Jul 2011, 07:07 AM

ClientScript.RegisterStartupScript(

this.GetType(), "EnableCabType", "UncheckSelectAll('" + chkJobCategoryAll.ClientID + "','" + cblJobCategory.ClientID + "','" + cblCabinetType.ClientID + "','" + chkCabinetAll.ClientID + "');", true);

Seems the above script not at all fired in the ItemDataBound event of RadGrid's popup. Need this to be fired only from ItemDataBound

Any workarounds

Thanks

Regards
Raj

 

6 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 27 Jul 2011, 05:25 AM
Hi Rajz,

Use the ScriptManager.RegisterStartupScript() method instead:
ScriptManager.RegisterStartupScript(Page, typeof(Page), "EnableCabType",
     "UncheckSelectAll('" + chkJobCategoryAll.ClientID + "','" + cblJobCategory.ClientID + "','" + cblCabinetType.ClientID + "','" + chkCabinetAll.ClientID + "');", true);


Greetings,
Iana
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.

0
wilbert
Top achievements
Rank 1
answered on 10 Jun 2014, 05:29 AM
same condition in posting,, it's not firing in ItemDataBound Ragrid eventhough I already use that code
  //disable img
 ScriptManager.RegisterStartupScript(Page, typeof(Page), "script",
"<script type='text/javascript'>$('[ID*=DivImgSelect]').off('click');</script>", false);
can you give me information about that ?
0
wilbert
Top achievements
Rank 1
answered on 11 Jun 2014, 08:35 AM
so anyone can't give the solution,,,, help please ? I want to know
0
Princy
Top achievements
Rank 2
answered on 12 Jun 2014, 04:46 AM
Hi Wilbert,

I'm not clear about your requirement, i guess you want to cancel an ImageButton click, which is inside an ItemTemplate. You can try the following code snippet.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
   GridDataItem dataItem = (GridDataItem)e.Item;    
   ImageButton imbShow = (ImageButton)dataItem.FindControl("imbShow");
   imbShow.Attributes.Add("onClick", "CancelClick('"+imbShow.ClientID+"');return false;");  
  }
}

JS:
<script type="text/javascript">
    function CancelClick(img) {
        return false;
    }   
</script>

Thanks,
Princy
0
wilbert
Top achievements
Rank 1
answered on 12 Jun 2014, 06:37 AM
Hi Princy

FYI I Want to appear data when in first load on condition disable Jquery function can't work so I put  ScriptManager.RegisterStartupScript(Page, Page.GetType(), "1", "Sys.Application.add_load(function(){{alert('success');}}, 0);", true); in itemdatabound to appear it, but it doesn't work
0
Princy
Top achievements
Rank 2
answered on 13 Jun 2014, 06:28 AM
Hi Wilbert,

Please try the following code snippet.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{   
  if (e.Item is GridDataItem)
  {      
   string script = "function f(){Check(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
   ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
  }
}

JS:
<script type="text/javascript">
    function Check() {
        alert("Fired");
    }
</script>

Thanks,
Princy
Tags
Grid
Asked by
Rajz
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
wilbert
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or