Hi,
I've really struggled with this for a couple of days now and have tried several approaches. I'm trying to use a toolbar button to add a record to my sql database and then refresh the data shown in my RadGrid to display the new record and then open a RadWindow to edit the new record.
I've got a toolbar button that when clicked runs the following jscript :-
This calls the server-side code which successfully creates the sql record :-
The above code works and the RadGrid1 is refreshed by my RadAjaxManager showing the new record. The hidden inputs value is set and the messagebox appears with the correct index of the new record.
The next bit of code is where I'm struggling. Although the code behind has set the value of the Hidden_idx control I just can't ssem to find this control with the client side code. I just keep getting null :-
Can you spot where I'm going wrong? Is there a better way of doing this? I've tried setting the innerhtml of a div which I could find with getElementByID but the innerhtml was always empty when read client-side even though the server side had set and read the value.
Thanks in advance for any help with this.
Jase
I've really struggled with this for a couple of days now and have tried several approaches. I'm trying to use a toolbar button to add a record to my sql database and then refresh the data shown in my RadGrid to display the new record and then open a RadWindow to edit the new record.
I've got a toolbar button that when clicked runs the following jscript :-
switch (button.get_value()) { |
case "AddInstance": |
var treeview = $find("<%=RadTreeView1.ClientID %>"); |
var treeNode = treeview.get_selectedNode(); |
if (treeNode == null) { |
alert("Select an application first"); |
break; |
}; |
var application_id = treeNode.get_value(); |
var arguements = "AddInstance," + application_id; |
RadAjaxManager1.ajaxRequest(arguements); |
break; |
} |
This calls the server-side code which successfully creates the sql record :-
Protected Sub RadAjaxManager1_OnAjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Dim splitArguements As Array = Split(e.Argument, ",") |
Dim strFunction As String = splitArguements(0) |
Dim intIndex As Integer = splitArguements(1) |
Select Case strFunction |
Case "AddInstance" |
Dim hidden_idx As HtmlInputHidden = FindControl("hidden_idx") |
SqlDataSource2.InsertParameters("instance_name").DefaultValue = "New Instance - " & CStr(Now) |
SqlDataSource2.InsertParameters("application_id").DefaultValue = intIndex |
SqlDataSource2.InsertParameters("testing_environment_id").DefaultValue = 1 |
SqlDataSource2.Insert() |
hidden_idx.Value = CStr(NewInstanceId) |
RadGrid1.Rebind() |
MsgBox(hidden_idx.Value) |
End Select End Sub |
Private Sub SqlDataSource2_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource2.Inserted |
NewInstanceId = e.Command.Parameters("@instance_id").Value.ToString |
End Sub |
The above code works and the RadGrid1 is refreshed by my RadAjaxManager showing the new record. The hidden inputs value is set and the messagebox appears with the correct index of the new record.
The next bit of code is where I'm struggling. Although the code behind has set the value of the Hidden_idx control I just can't ssem to find this control with the client side code. I just keep getting null :-
<body style="border:50px;"> |
<form id="form1" runat="server"> |
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
<script type="text/javascript"> |
function RadAjaxManager1_OnResponseEnd(sender, args) { |
var hidden_input = $find("<%=Hidden_idx.ClientID %>"); |
alert(hidden_input); |
var idx = hidden_input.value |
alert(idx); |
window.radopen("InstanceDetails.aspx?instance_id=" + instance_id, "RadWindow1"); |
} |
</script> |
</telerik:RadCodeBlock> |
<input type="hidden" id="Hidden_idx" name="Hidden_idx" runat="server" /> |
Can you spot where I'm going wrong? Is there a better way of doing this? I've tried setting the innerhtml of a div which I could find with getElementByID but the innerhtml was always empty when read client-side even though the server side had set and read the value.
Thanks in advance for any help with this.
Jase