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

button not work after update

3 Answers 122 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Mohamadreza
Top achievements
Rank 1
Mohamadreza asked on 13 Feb 2014, 12:08 AM
hi
i have a radbutton:

<telerik:RadButton ID="btnRegisterOrder" runat="server" Height="65px"
                                                            Text="ثبت سفارش" Width="160px" Font-Size="Large"><Icon PrimaryIconUrl="images/iconIco/accept.ico"  /></telerik:RadButton>

and this button will updated in radajaxmanager:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
  <AjaxSettings>
                     <telerik:AjaxSetting AjaxControlID="btnAddToList">
              <UpdatedControls>
                  <telerik:AjaxUpdatedControl ControlID="RadFileExplorer2" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="imgfront"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="imgback"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="imgfrontfilm"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="imgbackfilm"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="hfClientFileSelectForNewOrder"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="hdnImg1"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="hdnImg2"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="hdnImg3"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="hdnImg4"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="RadGrid7"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="btnRegisterOrder"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="radnotification1"></telerik:AjaxUpdatedControl>
              </UpdatedControls>
               
          </telerik:AjaxSetting>
          <telerik:AjaxSetting AjaxControlID="radToolBarFilterInvoices">
              <UpdatedControls>
                   
                  <telerik:AjaxUpdatedControl ControlID="RadGrid3" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                  <telerik:AjaxUpdatedControl ControlID="RadWindow1"></telerik:AjaxUpdatedControl>
                              
              </UpdatedControls>
           
          </telerik:AjaxSetting>
          <telerik:AjaxSetting AjaxControlID="radgrid3">
              <UpdatedControls>
                   
                  <telerik:AjaxUpdatedControl ControlID="RadGrid3" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                              
              </UpdatedControls>
           
          </telerik:AjaxSetting>
           
      </AjaxSettings>
       
  </telerik:RadAjaxManager>

after update, the button not working.

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 17 Feb 2014, 01:46 PM
Hello,

When configuring the settings of RadAjaxManager you should use AjaxControlID to set what control would initiate an Ajax request. In the UpdatedControls collection you would add the controls that are updated on that request. If you would like more information on RadAjaxManager and its configuration, it is available in this article.

In your setup it seems that you are using one button to update another. This is possible, however would you elaborate more on why are you using such settings? What is the scenario that you would like to achieve? I would appreciate it if you could share your full markup with the code-behind so we could have better understanding of what you would like to implement.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Mohamadreza
Top achievements
Rank 1
answered on 17 Feb 2014, 06:16 PM
thank you for reply.
in "btnAddToList" click, i get and or change some properties of oder control like datasource of "RadGrid7" and enable of "btnRegisterOrder". when not using ajax manager, all things work good. but when i am using ajax manager and change "btnRegisterOrder" enable to "true", then click event of "btnRegisterOrder" not fire.
my code is:
Protected Sub btnAddToList_Click(sender As Object, e As EventArgs) Handles btnAddToList.Click
 
    RadFileExplorer2.OnClientLoad = ""
    Dim f, b, ff, bf As Boolean
    If hdnImg1.Value <> "" Then
        f = True
    Else
        f = False
    End If
 
    If imgBack.Visible = False Then
        b = True
    Else
        If hdnImg2.Value = "" Then
            b = False
        Else
            Dim ffile As New MyFile(String.Format("{0}\{1}", general.physicalFolderName, hdnImg1.Value.Substring(hdnImg1.Value.IndexOf("userUpload"))))
            Dim bfile As New MyFile(String.Format("{0}\{1}", general.physicalFolderName, hdnImg2.Value.Substring(hdnImg2.Value.IndexOf("userUpload"))))
 
            If ffile.height = bfile.height And ffile.width = bfile.width Then
                b = True
            Else
                b = False
            End If
        End If
    End If
 
    If imgFronfFilm.Visible = False Then
        ff = True
    Else
        If hdnImg3.Value = "" Then
            ff = False
        Else
            ff = True
 
        End If
    End If
 
    If imgBackFilm.Visible = False Then
        bf = True
    Else
        If hdnImg4.Value = "" Then
            bf = False
        Else
            bf = True
        End If
    End If
 
    If f = False Or b = False Or ff = False Or bf = False Then
        RadNotification1.Text = "کارت ویزیت به درستی تنظیم نشده است. باید تمام تصاویر مورد نیاز انتخاب شده باشد و در ضمن پشت و روی کارت باید هم اندازه باشند"
        RadNotification1.Show()
        Exit Sub
    End If
 
    Dim det As New clsInvoiceDetail(NewInvoice)
    det.frontFile = New IO.FileInfo((String.Format("{0}\{1}", general.physicalFolderName, hdnImg1.Value.Substring(hdnImg1.Value.IndexOf("userUpload")))))
    If NewInvoice.ppr.sizeLimit Then
        Dim found As Boolean = False
 
        For Each sz As clsPprSize In NewInvoice.ppr.pprSize
            If sz.s = det.Lats Then
                found = True
                Exit For
            End If
        Next
        If found = False Then
            RadNotification1.Text = "در این جنس، شما محدود به سفارش در سایزهای تعریف شده هستید ولی فایل شما خارج از این محدودیت است. لطفا یا سایز فایل را اصلاح کنید یا فایل دیگری انتخاب نمائید یا اگر میخواهید حتما همین فایل را چاپ کنید اجناس دیگر را امتحان کنید."
            RadNotification1.Show()
            Exit Sub
        End If
    End If
 
    Dim s As Integer
    If NewInvoice.dbl = False Then
        s = NewInvoice.ppr.sheetS
    Else
        If NewInvoice.ppr.share Then
            s = NewInvoice.ppr.sheetS
        Else
            s = NewInvoice.ppr.sheetS / 2
 
        End If
    End If
 
    If (det.Lats * RadNumericTextBox1.Value) + NewInvoice.TotalLats > s Then
        RadNotification1.Text = "با توجه به ابعاد فایل انتخاب شده و تعداد درخواست شما، چاپ همه آنها در قالب یک سفارش مقدور نیست. لطفا سفارش خود را در فاکتورهای متعدد درخواست کنید"
        RadNotification1.Show()
        Exit Sub
 
    End If
 
 
 
    For i = 1 To RadNumericTextBox1.Value
        NewInvoice.details.Add(New clsInvoiceDetail(NewInvoice))
        NewInvoice.details(NewInvoice.details.Count - 1).frontFile = New IO.FileInfo((String.Format("{0}\{1}", general.physicalFolderName, hdnImg1.Value.Substring(hdnImg1.Value.IndexOf("userUpload")))))
        If imgBack.Visible = True Then
            NewInvoice.details(NewInvoice.details.Count - 1).backFile = New IO.FileInfo((String.Format("{0}\{1}", general.physicalFolderName, hdnImg2.Value.Substring(hdnImg2.Value.IndexOf("userUpload")))))
        End If
        If imgFronfFilm.Visible = True Then
            NewInvoice.details(NewInvoice.details.Count - 1).frontFilmFile = New IO.FileInfo((String.Format("{0}\{1}", general.physicalFolderName, hdnImg3.Value.Substring(hdnImg3.Value.IndexOf("userUpload")))))
        End If
        If imgBackFilm.Visible = True Then
            NewInvoice.details(NewInvoice.details.Count - 1).backFilmFile = New IO.FileInfo((String.Format("{0}\{1}", general.physicalFolderName, hdnImg4.Value.Substring(hdnImg4.Value.IndexOf("userUpload")))))
        End If
        If NewInvoice.details.Count = 1 Then
            NewInvoice.details(0).id = 1
        Else
            NewInvoice.details(NewInvoice.details.Count - 1).id = NewInvoice.details(NewInvoice.details.Count - 2).id + 1
        End If
 
    Next
 
    grig1Binding()
    RadNumericTextBox1.Text = 1
    RadNumericTextBox1.Value = 1
    hdnImg1.Value = ""
    hdnImg2.Value = ""
    hdnImg3.Value = ""
    hdnImg4.Value = ""
End Sub

and "grig1Binding()" method is:
Private Sub grig1Binding()
    RadGrid1.DataSource = NewInvoice.details
    RadGrid1.DataBind()
 
    If NewInvoice.dbl Then
        imgBack.Visible = True
        imgBackFilm.Visible = True
    Else
        imgBack.Visible = False
        imgBackFilm.Visible = False
    End If
    If NewInvoice.ppr.haveFilm Then
        imgFronfFilm.Visible = True
    Else
        imgFronfFilm.Visible = False
        imgBackFilm.Visible = False
    End If
    RadGrid1.Columns(1).Visible = imgBack.Visible
    RadGrid1.Columns(2).Visible = imgFronfFilm.Visible
    RadGrid1.Columns(3).Visible = imgBackFilm.Visible
    If NewInvoice.details.Count = 0 Then
        Using cmdItem As GridCommandItem = DirectCast(RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)
            Using rdtb As RadToolBar = TryCast(cmdItem.FindControl("RadToolBar3"), RadToolBar)
                DirectCast(rdtb.FindItemByValue("apply"), RadToolBarButton).Enabled = False
            End Using
        End Using
        btnRegisterOrder.Enabled = False
    Else
        Using cmdItem As GridCommandItem = DirectCast(RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)
            Using rdtb As RadToolBar = TryCast(cmdItem.FindControl("RadToolBar3"), RadToolBar)
                DirectCast(rdtb.FindItemByValue("apply"), RadToolBarButton).Enabled = True
            End Using
        End Using
        btnRegisterOrder.Enabled = True
    End If
 
    RadFileExplorer2.Configuration.ContentProviderTypeName = GetType(CustomProvider).AssemblyQualifiedName
 
 
 
End Sub

my problem is: after update control in ajax, "btnRegisterOrder" click event not fire.
0
Viktor Tachev
Telerik team
answered on 20 Feb 2014, 10:36 AM
Hello,

It seems that the Button btnRegisterOrder is not added to the AjaxSettings as initiator, it is only placed in the UpdatedControls collection for btnAddToList. Because of this nothing seems to happen when you click it and Ajax is enabled.

You need to modify the settings for RadAjaxManager and add btnRegisterOrder as an Ajax initiator and place the controls that would be updated by it in the UpdatedControls collection. Check out a simplified version of such settings below.

<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="btnAddToList">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="btnRegisterOrder" />
                <telerik:AjaxUpdatedControl ControlID="Label1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="btnRegisterOrder">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Label1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

In the sample scenario I used the following handlers for the buttons:

Protected Sub btnAddToList_Click(sender As Object, e As EventArgs) Handles btnAddToList.Click
    btnRegisterOrder.Enabled = True
    Label1.Text = "update from add button"
End Sub
 
Protected Sub btnRegisterOrder_Click(sender As Object, e As EventArgs) Handles btnRegisterOrder.Click
    Label1.Text = "update from registerOrder button"
End Sub

Try using similar approach for the settings of RadAjaxManager in your scenario and you should achieve the result you are looking for.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Ajax
Asked by
Mohamadreza
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Mohamadreza
Top achievements
Rank 1
Share this question
or