unable to locate the div control in masterpage when i'm in childpage...

Last post 07-03-2009 4:52 AM by mohd786hussain. 6 replies.

Sort Posts:

  • unable to locate the div control in masterpage when i'm in childpage...

    07-02-2009, 5:12 AM
    • Member
      43 point Member
    • pinoyz
    • Member since 02-11-2008, 4:28 AM
    • Posts 178

     Hi,

    I have a problem regarding control(div) in masterpage... i want is to have a control on div(html control) when i'm in the contentplaceholder of the childpage but i can't find how to do it...

    i can control textbox, label and button( i can't find the control for div)

     

    masterpage = Materpage.master

    childpage = default.aspx

    3 Stars and a Sun
  • Re: unable to locate the div control in masterpage when i'm in childpage...

    07-02-2009, 9:44 AM
    • Contributor
      5,138 point Contributor
    • papabear
    • Member since 08-08-2005, 3:49 PM
    • Posts 851

    You have to do some things

    add runat="server" and an ID to the div tag so that .net can 'see' it
    <div runat="server" ID="myDiv"> .... </div>

    and either

     - expose it on the Master Page so you can access directly:
    public Control MyDiv
    {get { return myDiv; } }

    or try to find it using FindControl

    - Master.FindControl("myDiv")...

    But the biggie is to give it an ID and the runat...

    Hope that helps,

    m


    give me suggestions for what to blog... http://www.myfriedmind.com/techblog -> thx

    Mark as "Answered" if this solves that wee old problem...
  • Re: unable to locate the div control in masterpage when i'm in childpage...

    07-02-2009, 9:20 PM
    • Member
      43 point Member
    • pinoyz
    • Member since 02-11-2008, 4:28 AM
    • Posts 178

     Hi,

    Thanks for the reply... anyway what kind of control is <div> to instantiate with the object...

    for example:

    Dim x as ? = master.FindControl("mydiv1")

    Best Regards,

    Ian

    3 Stars and a Sun
  • Re: unable to locate the div control in masterpage when i'm in childpage...

    07-03-2009, 1:33 AM
    • Member
      636 point Member
    • ChaitanyaC
    • Member since 06-06-2009, 4:30 AM
    • Mumbai
    • Posts 94

    See, as div is html control, you will not find anything in your vb page in find control related to that as it only shows asp controls, Panel which is one kind of division, so you may assign it or just keep it as Object 

    Try this:

    Dim x as Object = master.FindControl("mydiv1")

    or

    Dim x as Panel = master.FindControl("mydiv1")

    ** Mark any post that really helps you as “ANSWER” to indicate all other viewers in future for reference; **
    Thnks,
  • Re: unable to locate the div control in masterpage when i'm in childpage...

    07-03-2009, 1:45 AM
    Answer

    Hi,

    div is treated as HtmlGenericControl.

    So find it :

    Dim c as HtmlGenericControl = (HtmlGenericControl)masterpage.FindControl("");


    Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution.
    Mohammad Hussain
    http://mohdhussain.blogspot.com/
  • Re: unable to locate the div control in masterpage when i'm in childpage...

    07-03-2009, 4:48 AM
    • Member
      43 point Member
    • pinoyz
    • Member since 02-11-2008, 4:28 AM
    • Posts 178

     Hi,

    Thanks...

    Another Question: How can i manipulate the Style of the DIV?

    3 Stars and a Sun
  • Re: unable to locate the div control in masterpage when i'm in childpage...

    07-03-2009, 4:52 AM

    pinoyz:

     Hi,

    Thanks...

    Another Question: How can i manipulate the Style of the DIV?

    Hi,

    It is not a big task you can set it in server-side :

    divid.Style["attribute"]="value of style";

    like :

    divid.Style["display"]="none";

    Always "Mark as Answer" the Post That Solves the problem.Because It helps others to find the solution.
    Mohammad Hussain
    http://mohdhussain.blogspot.com/
Page 1 of 1 (7 items)