rebind grid in the content page on clicking a button on a usercontrol on the radwindow
Protected Sub imgbtnSearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbtnSearch.Click
Dim strScript As String
strScript =
"<script language=javascript>"
strScript +=
"top.$get('btnRebindGrid').click();"
strScript +=
"<"
strScript +=
"/script>"
Page.RegisterStartupScript(
"MSGE", strScript)
End Sub
Its working for a normal page.bt wen i include master page its not workg
8 Answers, 1 is accepted
If btnRebindGrid is in an user control, its ID will be changed when the control is rendered on the page. It is better to use the ClientID of the button - $get('<%= btnRebindGrid.ClientID %>')
All the best,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Sir, I have a Page, say Page1.aspx which is a content page ie,master page is included .In it a radGrid and link button is placed When I click on the linkbutton, a radwindow with a usercontrol is loaded. ie, in Page1.aspx.vb Protected Sub lnkFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFilter.Click Dim newWindow As Telerik.Web.UI.RadWindow = New Telerik.Web.UI.RadWindow newWindow.ID = "RadWindow3" newWindow.NavigateUrl = "Custom_Search_Page.aspx" newWindow.VisibleOnPageLoad = True newWindow.ReloadOnShow = True end sub
Inside Custom_Search_Page.aspx ,I placed a usercontrol ie, in Custom_Search_Page.aspx Inside <form id="form1" runat="server"><div> <uc1:CustomSearch id="uclCustomSearch" runat="server" /> </div> </form> That usercontrol contains a buttonWhile clicking on tht button I want to rebind the grid in Page1 |
|
I tried with
top.$get("btnRebindGrid").click(); |
I m gettg the javascript error
'top.$get(..)is null or not an object when i write it in code behind of usercontrol and i found tht this error is due to masterpage inclusion.. ie, Usercontrol.ascx.vb Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim strScript As String strScript = "<script language=javascript>" strScript += "top.$get('btnRebindGrid').click();" strScript += "<" strScript += "/script>" Page.RegisterStartupScript("MSGE", strScript) Page1.aspx<asp:Button ID="btnRebindGrid" runat="server" Text="RebindGrid" style="display:none" /> Page1.aspx.vbProtected Sub btnRebindGrid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRebindGrid.Click WorkDetailsGrid.Rebind() End Sub |
I notice that in your code you have:
top.$get('btnRebindGrid').click();
But in Georgi's solution it says:
$get('<%= btnRebindGrid.ClientID %>')
If you modify it to read like what Georgi said, does that make it work?
<
script type="text/javascript">
function RebindGrid()
{
top.$get(
'<%=btnRebindGrid.ClientID %>').click();
}
</script>
<
asp:Button runat="server" Text="Click" OnClientClick="RebindGrid" />
It gives a error
Error 24 Name 'btnRebindGrid' is not declared
when I gave the actual id got frm IE->View source.Its wrking.But its only on button client side click
ie,
<%
@ Control Language="VB" AutoEventWireup="false" CodeFile="ab.ascx.vb" Inherits="ab" %>
<script type="text/javascript">
function RebindGrid()
{
top.$get(
'ctl00$ContentPlaceHolder1$btnRebindGrid').click();
}
</script>
<
asp:Button runat="server" Text="Click" OnClientClick="RebindGrid" />
On codebehind its not wrking
But when i use radajaxmanager,the
ScriptManager.RegisterStartupScript(imgbtnSearch,
Me.GetType(), "MSGE", strScript, False)
is not working
i have same problem like you, i think you are closer than me solving the problem, my mail ayhantay@yahoo.com would you send me your code about the problem plz?
I already answered your other thread and for your convenience I pasted my reply below:
I assume that most probably the problem comes from the fact that both the MasterPage and the User Control are INaming Containers - this means that they change the IDs of the controls they contain. This is general ASP.NET knowledge and you can reproduce the issue by using a standard control, e.g asp button instead of RadControl - you will get the same behavior and the button will not be found. However, if you cannot manage to solve the problem yourself, prepare a sample, fully runnable demo (with DB, if needed, e.g use Northwind), open a new support ticket and send it us along with detailed reproduction steps and explanations of the actual and the desired behavior.
Greetings,
Svetlina
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.