# accessing webcontainers from code

**URL:** <https://forum.xojo.com/t/accessing-webcontainers-from-code/34908>\
**Category:** General\
**Created:** [December 12, 2016, 1:29am UTC](https://forum.xojo.com/t/accessing-webcontainers-from-code/34908 "2016-12-12T01:29:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave\_duke](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/c77e96/32.png) [@dave\_duke](https://forum.xojo.com/u/dave_duke)\
**Post date:** [December 12, 2016, 1:29am UTC](https://forum.xojo.com/t/accessing-webcontainers-from-code/34908/1 "2016-12-12T01:29:09Z")

</div>

I have  
Dim c As New MyContainer  
c.LockRight = True  
c.LockBottom = True  
c.EmbedWithin(Self, 0, 0, c.Width, c.Height)  
Dim d As New MyContainer  
d.LockRight = True  
d.LockBottom = True  
d.EmbedWithin(Self, 0, 0, c.Width, c.Height)

if I want to control the two containers (eg change contents) via code, how do I know what the container is called inside the webpage?  
would it be mycontainer1 , mycontainer2?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 12, 2016, 1:33am UTC](https://forum.xojo.com/t/accessing-webcontainers-from-code/34908/2 "2016-12-12T01:33:33Z")

</div>

Using your variable names it would be `c` and `d`. I would recommend using something much more descriptive.

If you don’t retain them in a property of the webpage, you’ll have to iterate through all controls on the page to find them again once they go out of scope at the end of the method.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 12, 2016, 2:36am UTC](https://forum.xojo.com/t/accessing-webcontainers-from-code/34908/3 "2016-12-12T02:36:11Z")

</div>

[quote=302787:@dave duke]I haveif I want to control the two containers (eg change contents) via code, how do I know what the container is called inside the webpage?  
would it be mycontainer1 , mycontainer2?[/quote]

May I suggest next time you post code you select it and click the code icon \<[\>] on top of the editor. It will be more legible.

Instead of DIMming c and d, make them a property of the WebPage, so you can refer to your WebContainers outside of this code. Otherwise they simply have no name at all.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 12, 2016, 6:02am UTC](https://forum.xojo.com/t/accessing-webcontainers-from-code/34908/6 "2016-12-12T06:02:09Z")

</div>

For example code, a single letter is okay - it’s only trying to show the general idea.

Did you understand where the variable name that you’ll need to reference comes from?  
Happy to elaborate if you have any questions 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:34pm UTC](https://forum.xojo.com/t/accessing-webcontainers-from-code/34908/7 "2020-10-29T18:34:44Z")

</div>


