Master / ContentTemplate / UpdatePanel / UserControl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimVtoo
    New Member
    • Jul 2008
    • 22

    Master / ContentTemplate / UpdatePanel / UserControl

    asp VB.NET

    How can I pass a value to my user controls in the example below From the Master Page?... it's driving me nuts!
    The scenario:
    Code:
    <MasterPage>
    <UpdateTrigger/>
    
    <ContentPlaceHolder 1>
        < asynch  UpdatePanel>
            <UserControl 1/>
        </ asynch UpdatePanel>
    </ContentPlaceHolder>
    
    <ContentPlaceHolder 2>
        < asynch UpdatePanel>
             *** <UserControl 2/> ***
        </ asynch UpdatePanel>
    </ContentPlaceHolder>
    
    </MasterPage>
    I have tried to illustrate my scenario above because I am rubish at explaining myself and the real code would be far to much to post, and is split across multiple pages....ie: master / content / user control ..etc.

    I have managed to pass a value to user control 1 by creating it dynamicaly and setting an attribute for it before adding adding it to the updatepanel.con tenttemplate. But cant do it this way for user control 2!

    Thanks in advance.

    Tim
    Last edited by pbmods; Feb 7 '09, 07:58 PM. Reason: Added CODE tags.
  • amirghaffarie1362
    New Member
    • Jan 2009
    • 19

    #2
    search about interface layer in asp.net in google ,

    Comment

    • TimVtoo
      New Member
      • Jul 2008
      • 22

      #3
      I've spent all weekend and much of last week googling this one... I think Interface Layer is a bit of a broad subject for my specific question ??

      I have worked around this now by doing away with the user control and just coding it in the update panel, but I would still like to know the answer if anyone can help ??

      Thanks

      Tim

      Comment

      • TimVtoo
        New Member
        • Jul 2008
        • 22

        #4
        Some kind of response here would be good. Everytime I work around this problem it raises it's ugly head again.... it must be doable??

        Pleeeaaase, someone throw me a bone??

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Ok, I'm not sure what the problem is.
          You have a UserControl, it's much like a class, it has Properties and Public methods that can expose data to the parent container.

          In this case the MasterPage is your parent container.

          So if you add Properties and Public methods to your User Control, then your MasterPage will be able to access information provided by that control.

          Comment

          • TimVtoo
            New Member
            • Jul 2008
            • 22

            #6
            Thanks Frin, but what about the UpdatePanel?...
            I've tried everything (in my very limited arsenol), but just cant get info in or out of that usercontrol INSIDE the update panel ??

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              I have no idea why you would have a problem with this.
              I place User Controls in UpdatePanels all the time and have no problem accessing their properties in the parent page....and I don't Have to create them dynamically in order to do this either.

              What have you tried to solve the problem?
              Could you provide more details about what you are trying to access in the MasterPage and when you are trying to access that data?

              Mind you I haven't really tried placing them directly in the master page....I use Content Pages, which contain the User Controls.

              Let's see if we can't figure this out.

              -Frinny

              Comment

              • TimVtoo
                New Member
                • Jul 2008
                • 22

                #8
                OK, I'll try to explain...
                I have a master page with 2 ContentPlaceHol ders. 1 of these ContentPlaceHol ders has a gridview. When you click an item in the gridview. Using javascript, this puts a value in a texbox in the master page and clickes a button which triggers the update panels (1 in each contentplacehol der).

                I would like either:
                the user controls in the update panels to access the value in the textbox on the master so they get thier results based on that value
                OR
                the button click (trigger) event to set a property for each user control so they can display result based on the property value.

                As I understand it, to acees controls in a ContentPlaceHol der, I have to use the FindControl() method, but doing this does not expose the properties for the user control.... I hope that makes at least some sence??

                Thanks again for your time!

                Tim

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  You are going to have to have both controls and the TextBox in the same UpdatePanel in order for them to be able to access it's value during asynchronous postback.

                  Do you have to use the MasterPage or could you place both of these UserControls into a Content Page?

                  I think it would be a lot easier if you used a content page.
                  Your UserControl that contains the GridView could raise an event when the button is clicked...which the content page could handle and update the second UserControl. Please note that both controls are still going to have to be in the same update panel.

                  Comment

                  • TimVtoo
                    New Member
                    • Jul 2008
                    • 22

                    #10
                    At the moment the Master page has 2 columns. 1 UpdatePanel/UserControl in each. I did try puting both UC's in 1 UdtPnl and repositioning 1 of the UC's using css position:fixed. What I learnt there was that CSS will only position the content of a placeholer within that place holder. If you try to position beyond that placholder (ie: over the right column from the left hand column) it just gets croped and wont display. Probably obvious to you experienced types!

                    I think tomorrow I will ditch the Master Page for this particular page and re-create it on it's own. That way I should be able to access my user controls properties directly right??

                    Am I right in thinking that the problems I'm having accessing my U'Control properties is because I'm having to use FindControl() to get around my Master/Content elements?

                    Sorry for sounding a bit of a muppet, but it's all new to me and it seems I've managed to cram a bad combination of tools and controls together on my first project causing me alot of confusion.... trying to run before I can walk I guess.

                    Thanks again Frinny

                    Comment

                    Working...