?
Solved

Programatically change <div id="someid"> tag in ASP.NET.  when runat="server" not available

Posted on 2010-03-31
6
Medium Priority
?
1,037 Views
Last Modified: 2012-05-09
I'm working with a tab control that's generated from a javascript library. I'm able to assign ids to the various tab panels for example <div id="panel1">, <div id="panel2">.  I'm trying to programmatically assign varying content to the various tab panels using vb.net.  However, because the panels are dynamically created by the javascript when the page loads, i'm not able to assign the runat='server' attribute in the div tag.  How to i reference these <div> id's in my code?
0
Comment
Question by:todd_nakasato
6 Comments
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 29260022
how are you setting up runat attribute in javascript?

var d = document.createElement("div")
d.setAttribute("runat", "server")


did you consider adding server div controls using vb/c# instead?
0
 

Author Comment

by:todd_nakasato
ID: 29261345
the javascript is generated directly from a extjs panel control.  
0
 
LVL 28

Accepted Solution

by:
sybe earned 750 total points
ID: 29320118
Well, of course if something is created on the client, your server-side code can not touch it.

But you have some options:
1. Pass (server-side generated) values of parameters along to the javascript library.
2. Get the desired content of divs through an AJAX call.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 28

Expert Comment

by:sybe
ID: 29320572
Just wondering how you imagine a div that is created on the client to be running on the server?

ASP.Net is even worse than other web languages in that fools developers into thinking that there is no difference between client-side script and server-side script. So maybe you are forgiven.

But you should really understand that once the HTML has been sent to the browser, the server has no longer any control about what happens. From that moment it is the browser that takes control about what happens.
You might have included some javascripts in the HTML, but there is no guarantee that the browser will execute that javascript.
0
 
LVL 3

Assisted Solution

by:Stormjack
Stormjack earned 750 total points
ID: 29409009
Use the AJAX tab container from the Microsoft library.  You can interact with its properties in the code behind, set the contents of its panels, change the tab text, etc.
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Tabs/Tabs.aspx

I use this heavily in several applications and it works like a champ.
0
 

Author Closing Comment

by:todd_nakasato
ID: 31709642
thanks
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question