Click here to Skip to main content
15,443,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am exported .html file in tabular form using string builder on button event so i want to give links to .html file records how i can show links on html file using string builder in asp.net
reply early......

thanks
Posted
Updated 14-Feb-12 20:16pm
v2
Comments
Michael dg 15-Feb-12 2:36am    
Where do you put or export the html? directly to the Response object or to the system directory of your web server?
dA.d 15-Feb-12 5:57am    
i am export the datatable into html file using string builder on button click event. in that html file displaying two tables seperately so i want to give link to first table data that link going to second table data on same file.
dA.d 15-Feb-12 23:21pm     CRLF
i explain to u what is my problem..... this is code behind page code. button_click(object sender, EventArgs e) //event.... dataset = bal.storedprocedure(); //stored procedure call.... ToHTML(dataset.Tables[0], "SoftwareList.html", Page.Response); //function call...... public void ToHTML(DataTable dt, string filename, HttpResponse response) {var html = ConvertToHtmlFile(dt); } public static string ConvertToHtmlFile(DataTable GetTable) {//here i am using string builder myBuilder.Append("<html>"); myBuilder.Append("<head>"); myBuilder.Append("<title>"); myBuilder.Append("Page-"); myBuilder.Append(Guid.NewGuid().ToString()); myBuilder.Append("</title>"); myBuilder.Append("</head>"); myBuilder.Append("<body>"); //here i am create table columns and rows using tr & td tags and store data in that form //here i want give the links to second columns rows myBuilder.Append("</body>"); myBuilder.Append("</html>"); }

Try this way,you can add links
HTML
myBuilder.Append(" <a href="\"http://www.google.com\"">Google</a>");
 
Share this answer
 
Hi Dahale.
I think you should read more about anchor link in html. Check this out. HTML Links[^]

To give more an example, your exported html should look like this

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Export</title>
</head>
<body>
    <a id="top" href="#table1">Table 1</a>
    <a href="#table2">Table 2</a> 
    <span>Start of Table 1</span>
    <table id="table1">
         <tr>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
        </tr>
    </table>
    <a href="#top">Go to Top</a>
    <span>Start of Table 2</span>
    <table id="table2">
         <tr>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
        </tr>
    </table>
    <a href="#top">Go to Top</a>
</body>
</html>


Please observe the href of Table 1 and Table 2 link they are pointing to the id of another html element. When the user click on that link, the browser will automatically navigate/scroll to target element, the above example it will navigate/scroll to table1 element.

If you accept this answer, please mark you question as solved.
 
Share this answer
 
Hi Dahale.
I think you should read more about anchor link in html. Check this out. HTML Links[^]

To give more an example, your exported html should look like this

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Export</title>
</head>
<body>
    <a id="top" href="#table1">Table 1</a>
    <a href="#table2">Table 2</a> 
    <span>Start of Table 1</span>
    <table id="table1">
         <tr>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
        </tr>
    </table>

    <span>Start of Table 2</span>
    <table id="table2">
         <tr>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
            <td>
                Cell 1
            </td>
        </tr>
    </table>
    <a href="#top">Go to Top</a>
</body>
</html>


Please observe the href of Table 1 and Table 2 link they are pointing to the id of another html element. When the user click on that link, the browser will automatically navigate to that element.

If you accept this answer, please mark you question as solved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900