views:

28

answers:

1

I am a newbie in asp.net. I am trying to load the text and the URL into hyperlink from a database. After debugging, I found out that the value is successfully loaded into the hyperlink control, however it doesn't shows at the html code? Does anyone knows how this happened? Sorry for my bad English.

                If myReader2.Read Then
                             Dim temp_panel As Panel
                            Dim temp_hyperlink As HyperLink                                
                            temp_panel = FindControlRecursive(Me, "Panel" & i.ToString())
                            temp_panel.CssClass = "accordionItem"                                
                            temp_hyperlink = FindControlRecursive(Me, "HyperLink" & (i).ToString())
                            temp_hyperlink.Text = myReader2("Text")
                            temp_hyperlink.NavigateUrl = myReader2("Link")
                            temp_hyperlink.CssClass = "accordionItem"
                            temp_hyperlink.RenderControl(o)
                            myConn2.Close()
                End If

above is the code-behind.

  <asp:Panel ID="Panel1" runat="server" class="accordionIteminvisible"><asp:HyperLink ID="HyperLink1" runat="server" /></asp:Panel>
                            <asp:Panel ID="Panel2" runat="server" class="accordionIteminvisible"><asp:HyperLink ID="HyperLink2" runat="server" /></asp:Panel>
                            <asp:Panel ID="Panel3" runat="server" class="accordionIteminvisible"><asp:HyperLink ID="HyperLink3" runat="server" /></asp:Panel>

above is the asp code.

                            <div id="ctl00_AccordionPane1_content_Panel1" class="accordionIteminvisible"> 

    </div> 
                            <div id="ctl00_AccordionPane1_content_Panel2" class="accordionIteminvisible"> 
        <a id="ctl00_AccordionPane1_content_HyperLink2"></a> 
    </div> 
                            <div id="ctl00_AccordionPane1_content_Panel3" class="accordionIteminvisible"> 
        <a id="ctl00_AccordionPane1_content_HyperLink3"></a> 
    </div> 

above is the html code.

+2  A: 

EDIT: The original poster answered his own question but marked this one as the answer. OP's solution:

The problem is that this page is my master page. There are also hyperlinks with the same name in the content page. Therefore the settings is made on the content page, not the master page. After changing the name of the hyperlinks on the master page it works.

====================================================================

Have you tried debugging the code? What happens when you reach

temp_hyperlink.Text = myReader2("Text")

What is the value of i?

What is the value of myReader2("Text")?

Do you find the link with temp_hyperlink ?

Edit: Even though there is nothing in html, do the links show on the page? What's the value of url in the reader? Have you tried using the asp:linkbutton instead?

adrianos
i have solve the problem, thanks for answering also.
Gan Juan Yao
Post up your answer and mark it as the answer
adrianos
yes i have tired to debugged it. The problem is that this page is my master page. There are also hyperlinks with the same name in the content page. Therefore the settings is made on the content page, not the master page. After changing the name of the hyperlinks on the master page it works. Thanks alot.
Gan Juan Yao
You don't need to mark my answer as the answer as I didn't solve it - you did! You can add your own answer and mark that as the answer - then others with the same problem can see how you fixed it.
adrianos