I have a bit of a problem with a page that needs some re-writing.
Basically, the page on $(document).ready calls via ajax a web service and gets a json object back and then uses that object and a template to generate the page. This works perfectly… until you turn js off and then you just see a blank page.
Anyways, I have been told to make it work for non-js people… and indexable re Google
Now ordinarily I would just make something like <asp:label id="name" runat="server"> and then in code behind fill it. But due to all the other JS that is attached to the page to the different divs and labels etc I am trying to avoid this. E.g. Masonry js is attached amongst others.
Obviously if I change the stuff to runat server then the ids change.
So the question, can I just have in the aspx page simple html and e.g. <%= presult.Name %> and in the code behind something like AWebService ws = new AWebService(); var result = ws.Getdata.... and then made the ‘result’ public with public MyClass presult {get;set;}
Question: Is there any performance problem in doing this over the alternative of making labels runat=server? Is there any other glaring problem in doing this (I have never used .net in this way on the aspx page with <%%> tags. Have read about it, but never used it…. It would seem a more ‘light weight’ alternative given it avoids all the extra stuff put in if you use a server side control label…
Note: I was looking at MVC today amongst my readings. Am I correct in saying that if I don’t have runat=server but the other way above that it is kind of like MVC using the aspx view engine ?
Also, I have seen the posts re making ajax calls #! but we are trying to avoid using those hash tags if possible.
Thanks in advance
Cheers,
Robin
EDIT
As a note, to avoid jumbled client side ids on controls, .net 4.0 has the ClientIDMode which you can set to static….
There’s nothing wrong with the approach you are trying to take.
But i would rather put the result inside a couple of noscript tags to ensure they only get displayed when js is turned off.