The solution I ended up with, was to set the HTML of to invisible divs, DivA and DivB, at Page_Load.
Then, in JavaScript, depending on the innerwidth property (and on the resize event), I could set the divs to visible/invisible.
Very simple solution, compared to what I was trying to do. Yes, it gives a little bit more rendered HTML, but at least it works and it's fast.