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

Fill form controls and radgrid with AjaxPanels

5 Answers 80 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Quim
Top achievements
Rank 1
Quim asked on 07 Nov 2008, 05:50 PM
Hi

I'm trying to create one aspx page for each table in my database in order to update them.
My page has a Radgrid to select items to edit.

I'm using 3 DIVs, one with RadGrid, another with the buttons to edit an add new items and a third div with all controls needed to fill my database table.
When div Datagrid is visible, div controls is invisible. This is working ok with client code that I execute from the server using AjaxMaster
My controls will use asp.net validators when ok button is clicked.
All my database accesses are done through server code.

I done a lot of configurations with Ajax but there are always a problem.

All my buttons are related with server events, before I start with client code events  that call server code through Ajaxrequest, but then I got problems with my asp.net validators that wont fired.

The situation I have now is like this:
============================

I put one AjaxPanel inside each DIV:
RadAjaxLoadingPanel3 has Button bt_edit, bt_new, label with selected radgrid item and some hidden fields that I need in server side
RadAjaxLoadingPanel2 has RadGrid
RadAjaxLoadingPanel1 has all the controls I need to fill and also my butons bt_ok and bt_cancelar to validade or cancel.

At this stage, Edit and Add buttons are working, my validators are working but I havesame problems to solve when I press ok button to validate my controls:
> when reading RadInput textboxes on server code, the text value I get is the old value before I make the changes. If I use a normal text box, this works ok. (Radtexbox example:  <telerik:RadTextBox ID="tx_match_user" runat="server"></telerik:RadTextBox>)
> After saving data I need to refresh Radgrid and my code don't work. I'm using this code in another page and it wotks ok, but the call starts from a javascrip function, here it starts form server code
> when I select a grid item, i store the name in label that is inside RadAjaxLoadingPanel3. Every time I click bt_edit  or bt_new that are inside the same Radajaxpanel, this label gets empty.

The main parts of my code:
======================

My last MasterAjax configuration:

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="bt_edit">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="bt_new">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="Bt_ok">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="Bt_Cancelar">
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>


My server code to execute javascript from server (I try both ways and they do what I need):
Private Sub execute_js(ByVal script As String)
        ScriptManager.RegisterClientScriptBlock(Me, Page.GetType(), "PopupWindow", script, True)
        'RadAjaxManager1.ResponseScripts.Add(script)
    End Sub

My server code to refresh Radgrid that is called when I finish to update my database:

    Private Sub grid2_refresh(ByVal tipo As Integer)
        'obtem o tipo de operação efectuado
        If tipo = 2 Then RadGrid1.CurrentPageIndex = 0
        RadGrid1.DataSource = load_DBdata()
        RadGrid1.Rebind()
    End Sub

Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.DataBound
        rd.Close()
        cn.Close()
    End Sub

Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        RadGrid1.DataSource = load_DBdata()
    End Sub

  Private Function load_DBdata() As SqlDataReader
        Try
            cn = New SqlConnection
            cn.ConnectionString = DB_STRING
            cn.Open()

            Dim command As SqlCommand = New SqlCommand("Sp_Users_List", cn)
            With command
                .CommandType = Data.CommandType.StoredProcedure
                .Parameters.Add("@login_id", Data.SqlDbType.BigInt)
                .Parameters("@login_id").Value = 0
            End With
            '
            rd = command.ExecuteReader


        Catch ex As Exception

        Return rd
    End Function


Best regards



5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 11 Nov 2008, 09:19 AM
Hello Quim,

Please note that ASP Standard Validators on the client are officially not supported with Ajax. Please review the following help topic which elaborates on this matter.
Also could you please let me know if the control with ID RadAjaxPanel1 is Telerik RadAjaxPanel control. If yes please note that it is not supported scenario to add RadAjaxPanel into the RadAjaxManager settings.

Greetings,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Quim
Top achievements
Rank 1
answered on 12 Nov 2008, 07:16 PM
Hi

ok, I change my application and all my validation is on server side now.
I made a simple test with all my controlsinside one RadAjaxPanel.
My RadAjaxManager configuration is empty, but I notice that every time I click a button, a postback is fired.
It was not supposed that all the controls inside an AjaxPanel should fire their events without a postback?

Best regards
0
Iana Tsolova
Telerik team
answered on 13 Nov 2008, 11:13 AM
Hello Quim,

Can you confirm that the EnableAjax property of the RadAjaxPanel is set to true (the default value is true)? I suggest that you send us the whole problematic page (aspx/vb.net) so we could investigate your case in depth and provide a proper solution for you.
Additionally, you can review the Troubleshooting section in the RadAjax control online help and check if it helps.

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Quim
Top achievements
Rank 1
answered on 13 Nov 2008, 12:35 PM
Hi

I start changing my code to make it small and easy to figure, then i try a small page using a single AjaxPanel with one button and one label. I still have a postback when I click the button. Something should be wrong in my configuration. I'm using Q3 2008.

ASPX
====

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="teste.aspx.vb" Inherits="teste" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        &nbsp;<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    <div>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px" HorizontalAlign="NotSet" EnableAJAX="true">
            <asp:Button ID="Button1" runat="server" Text="Button"  />
            <asp:Label ID="Label1" runat="server" Text="Label" Width="208px"></asp:Label></telerik:RadAjaxPanel>
    
    </div>
    </form>
</body>
</html>

VB.NET
======

Partial Class teste
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = Date.Now.ToString
    End Sub

    Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
        If Not IsPostBack Then

        Else
            MsgBox("Postback")
        End If
    End Sub
End Class


Regards
0
Iana Tsolova
Telerik team
answered on 13 Nov 2008, 04:14 PM
Hi Quim,

I followed your scenario in order to replicate the described behavior but no avail. Please find attached a sample project and let me know how it behaves on your end.
Note that despite a page is ajaxified this is not affecting the page lifecycle, further more all server events are fired and executed the same way as upon regular postback. The difference is that the page updates partially, only the updated page content is rendered back on the client but the whole page.
Find more information here.

Let me know if I can assist you further.

All the best,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Quim
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Quim
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or