views:

841

answers:

3

I placed the scritmanager to masterpage. "scriptmanager1"

There is an updatepanel in the masterpage shows total. "updatepanel1"

In the contentpage I have nested listviews. the "listview2" inside the "listview1" has itemtemplate with a linkbutton called "addtoTotal"

I want to update the updatepanel1 inside the masterpage when user clicks to addtoTotal button.

updatepanel1's update mode is conditional.

How can I do this.

Firstly I could not findcontrol addtoTotal linkbutton.

Second how can I register this button to update updatepanel1

I want to triger the conditional updatepanel from the contentpage.

I tried to do something like this

protected void Page_Load(object sender, EventArgs e) { ScriptManager1.RegisterAsyncPostBackControl(myControl);

}

I could not. Because I don't know where to write this RegisterAsyncPostBackControl code. I could not findcontrol the linkbutton. I am not sure about the way I am trying to solve this is right way.

A: 

for finding the addtoTotal button I believe you are gonna have to do the following in the code behind

 ListView listview2 = (ListView)listview1.FindControl("listview2"); 
 LinkButton addtoTotal = (LinkButton)listview2.FindControl("addtoTotal");

you should be able to find the listview2 within the first listview and then find the LinkButton within listivew2

jmein
+1  A: 

You can put a subroutine on your master page that updates the panel and you can call it from the content page like so.

  Public Partial Class _Default1
        Inherits System.Web.UI.MasterPage

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        End Sub
        Public Sub updatedpage()
             updatepanel1.update()
        End Sub
    End Class


    Public Partial Class _Default5
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                LoadData()
            End If
            CType(Me.Master, _Default1).updatedpage()
        End Sub
    End Class
Middletone
@Middletone Thats so irrelevant answer..
Jack
As a seasoned developer I have dealt with this issue and understand how the relationship between the objects works well enought to know that being able to call across the objects is the best way to handle this sort of challenge. It's a code behind solution that works.
Middletone
If you think this is incorrect hen perhaps your question is poorly stated.
Middletone
Are you calling it irrelevant because it is VB whereas you are using C#? If so, grow up!
ck
A: 

I'm not quite sure that I understand your question but it seems to me that this article should point you in the right direction

dDejan
Thanks but I couldnt find useful this article for my problem. I want to update the updatepanel1 inside the masterpage when user clicks to addtoTotal button.
Jack