#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    14
    Rep Power
    0

    Double executed code in master pages


    Hi all,
    I have a site with dynamicly added buttons to a html table. The buttons should add or subtract 1 from a session variable (function ButtonHandler) and display the result in the html table (OnPreRender).
    As a single site all works fine but when used in a masterpage setup the code is somtimes! executed twice ?
    Can anybody tell my why and how to avoid double executed code?

    Dynmaicly part:
    Dim tbr as HTMLTableRow
    Dim tbc as HTMLTableCell
    Dim btnL = new HTMLButton()
    Dim btnR = new HTMLButton()

    tbr = new HTMLTableRow()

    tbc = new HTMLTableCell()
    tbc.Attributes.Add("id", "moveL")
    tbc.ColSpan = 2
    btnL.innerText = " < "
    btnL.id = "moveL"
    AddHandler btnL.ServerClick, AddressOf ButtonHandler
    tbc.Controls.Add(btnL)
    tbr.Cells.Add(tbc)

    tbc = new HTMLTableCell()
    tbc.Attributes.Add("id", "weektitle")
    tbc.Align = "center"
    tbc.id = "weektitle"
    tbc.innerText = Session("week")
    tbr.Cells.Add(tbc)

    tbc = new HTMLTableCell()
    tbc.Attributes.Add("id", "moveR")
    tbc.ColSpan = 2
    btnR.innerText = " > "
    btnR.id = "moveR"
    AddHandler btnR.ServerClick, AddressOf ButtonHandler
    tbc.Controls.Add(btnR)
    tbr.Cells.Add(tbc)

    tblSheet.Rows.Add(tbr)

    TIA acki4711
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,730
    Rep Power
    1959
    A quick search on "ASP master page called twice" had several results.
    Maybe one of these can help you:
    - http://stackoverflow.com/questions/9160423/master-pages-page-load-method-fires-twice
    - http://www.velocityreviews.com/forums/t21131-asp-net-page-load-twice-problem.html
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    14
    Rep Power
    0
    MrFujin,
    Thanks for your reply, but I did the google search myself as well before asking the question here.
    It's not a missing picture and and if it's the button that fires PageLoad again, why then not every time when I hit the button but only in 80% of the cases ??

    TIA
    acki4711
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Posts
    2
    Rep Power
    0
    This is very nice sharing i really like it very much this is very informative sharing and i get very much information from it
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    14
    Rep Power
    0
    Well, after hours, I could not figure out what it was.
    I removed the dynamic generation of the buttons and made them static and build/changed the dynamic part around the static elements. now it works... ?

IMN logo majestic logo threadwatch logo seochat tools logo