display hyperlink
-
I created div like this:
System.Web.UI.HtmlControls.HtmlGenericControl dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
And hyperlink like this:System.Web.UI.WebControls.HyperLink link = new System.Web.UI.WebControls.HyperLink(); link.NavigateUrl = "http://blabla.com"; link.Text = "Click here"; link.Target = "_blank";
Now I am trying to display this link in div that i could click on it. When I add link to div like this:dynDiv.InnerHtml= link;
It doesn't work. Help plz. -
I created div like this:
System.Web.UI.HtmlControls.HtmlGenericControl dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
And hyperlink like this:System.Web.UI.WebControls.HyperLink link = new System.Web.UI.WebControls.HyperLink(); link.NavigateUrl = "http://blabla.com"; link.Text = "Click here"; link.Target = "_blank";
Now I am trying to display this link in div that i could click on it. When I add link to div like this:dynDiv.InnerHtml= link;
It doesn't work. Help plz.What doesn't work? Where is the code to place the DIV in your UI? You need to add DIV dynamic control to some container such that it is visible. Once the Div is visible, all the contents present in it will be visible. Add controls to div and then add div to some container.
-
What doesn't work? Where is the code to place the DIV in your UI? You need to add DIV dynamic control to some container such that it is visible. Once the Div is visible, all the contents present in it will be visible. Add controls to div and then add div to some container.
-
I added it to my module like this:
this.Controls.Add(dynDiv);
And like i wrote before when i add innerhtml i get for link this output: System.Web.UI.WebControls.HyperLinkWhich line of my answer you were able to got? Adding a div to any container: You did:
this.Controls.Add(dynDiv);
totally WRONG Where is the container to which you added it? It would be something like if you have a panel in the page: Panel1.Controls.Add(dynDiv); Adding controls to the div: You did:dynDiv.InnerHtml= link;
again WRONG Is this the add the controls? It would be:dynDiv.Controls.Add(link);
You are done! I would suggest you to pick a book please. Read it. It will help improving fast. -
Which line of my answer you were able to got? Adding a div to any container: You did:
this.Controls.Add(dynDiv);
totally WRONG Where is the container to which you added it? It would be something like if you have a panel in the page: Panel1.Controls.Add(dynDiv); Adding controls to the div: You did:dynDiv.InnerHtml= link;
again WRONG Is this the add the controls? It would be:dynDiv.Controls.Add(link);
You are done! I would suggest you to pick a book please. Read it. It will help improving fast.If i add link as control to Panel, it works, but all the links are shown at the bottom. If i add links to div, i get error at page load. I have one div. Is it possible to show few hyperlinks at random places in div? For example i am getting some info and i am adding info in single div with div.Innerhtml+=info How could i add hyperlink at the end of one part of info? Hope you understand what i am trying to do.
-
If i add link as control to Panel, it works, but all the links are shown at the bottom. If i add links to div, i get error at page load. I have one div. Is it possible to show few hyperlinks at random places in div? For example i am getting some info and i am adding info in single div with div.Innerhtml+=info How could i add hyperlink at the end of one part of info? Hope you understand what i am trying to do.
instead use Panel1.Controls.Add(MyDiv); try using Panel1.Controls.AddAt(0, MyDiv); Where 0 is the position of the controls! ;)