Welcome Guest Search | Active Topics | Sign In | Register

update Treeview whit ajax Options
Rafo
Posted: Friday, November 9, 2007 9:17:22 AM
Rank: Member
Groups: Member

Joined: 11/9/2007
Posts: 15
Within my control. Ascx a treeview I want to update without the postback to make the whole page.
Full two lists and what apartir selected in the second list box add nodes to a group of treeview

my button
<input id="Button1" type="button" value="button" onclick="return Ejecutar()" /><br />

//Function of javascript
function Ejecutar() {
var message = 'Ejecutar';
var context = 'Map1'; //this variable is for update other control
<%=CallbackBotonEjecutar%>

}

...Treeview1.......

this code is of source

the codeBehind is next...
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent

If eventArgument.Contains("Ejecutar") Then
LLenaxOrganismo(TreeView1.Nodes.Item(1))

End If

End Sub

Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
Return _callbackArg
End Function

Private Sub LLenaxOrganismo(ByVal nodePadre As EO.Web.TreeNode)
con.ConnectionString = "Data Source=0.0.0.0;persist security info=True;Initial Catalog=database;User ID=user;password=psw"
con.Open()
Try
Dim cmd As SqlCommand = con.CreateCommand
cmd.CommandText = "spOrganismo"
cmd.Parameters.AddWithValue("@Organismo", ddlCriterio.Text) 'this ddlcriterio is a dropdonwlist to choose option text
cmd.CommandType = Data.CommandType.StoredProcedure
Dim da As New SqlDataAdapter(cmd)
Dim ds As New Data.DataSet
da.Fill(ds)

Dim dataViewHijos As Data.DataView
dataViewHijos = New Data.DataView(ds.Tables(0))
TreeView1.DataSource = ds
If TreeView1.Nodes.Item(1).SubGroup.Nodes.Item(0).Text = "Ductos" Then
For Each dataRowCurrent As Data.DataRowView In dataViewHijos
Dim nuevoNodo As New TreeNode
nuevoNodo.Text = dataRowCurrent("Ducto").ToString()
If nodePadre Is Nothing Then
TreeView1.Nodes.Add(nuevoNodo.Text)
Else
TreeView1.Nodes.Item(1).SubGroup.Nodes.Item(0).SubGroup.Nodes.Add (nuevoNodo.Text)
End If
Next dataRowCurrent
End If
Catch sqlEx As SqlException
'MsgBox(sqlEx.Message)
Catch ex As Exception
'MsgBox(ex.Message)
End Try
If con.State = Data.ConnectionState.Open Then
con.Close()
End If
'm_map is a control for a map
m_map.CallbackResults.Add(RefreshControlHtml(TreeView1))
_callbackArg = m_map.CallbackResults.ToString
End Sub

'whit this function refresh my ASP controls correctly
Private Function RefreshControlHtml(ByVal control As Control) As ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult
Dim sw As System.IO.StringWriter = New System.IO.StringWriter()
Dim writer As HtmlTextWriter = New HtmlTextWriter(sw)
control.RenderControl(writer) 'here send error
'Referencia a objeto no establecida como instancia de un objeto.
Dim htmlContent As String = sw.ToString()
sw.Close()
Return New ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(control, "content", htmlContent)
End Function

thanks for help me!!!!!
eo_support
Posted: Friday, November 9, 2007 9:33:44 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,089
Hi Rafo,

You over complicated it a bit. The easiest way is to put the TreeView into a CallbackPanel, set the TreeView's RaisesServerEvent to true and also set it as a Trigger of the panel and you will be all set. See here for more details:

http://www.essentialobjects.com/ViewDoc.aspx?t=Callback%2fwalkthru_productInfo.html

Our demo project uses CallbackPanel extensively. You can try to load the source code and see how it works. It's very easy to use.

Thanks
Rafo
Posted: Monday, November 12, 2007 8:02:13 AM
Rank: Member
Groups: Member

Joined: 11/9/2007
Posts: 15

Thanks for your answer, now my Treeview execute correctly whit callback





You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.