Home > Mobile >  Pass value of <h4>tag from one aspx page to another aspx page
Pass value of <h4>tag from one aspx page to another aspx page

Time:11-27

I am using an anchor tag in one aspx page to redirect to another aspx page .But I need to pass value of particluar h4 also from source to destination page so that I can display it on header .

first page.aspx

            <div  runat="server" id="line_1">
            <div >
                <div >
                    <table style="width: 100%">
                        <tr>
                            <td style="text-align: left; width: 75%">
                                <h4  id="line_name_1">Place1Line</h4>
                            </td>
                        </tr>
                    </table>
                    <a href="LinePage.aspx" ></a>
                </div>
                  <div >
                    </div>
                </div>
           </div>
                       <div  runat="server" id="line_2">
            <div >
                <div >
                    <table style="width: 100%">
                        <tr>
                            <td style="text-align: left; width: 75%">
                                <h4  id="line_name_2">Place2Line</h4>
                            </td>
                        </tr>
                    </table>
                    <a href="LinePage.aspx" ></a>
                </div>
                  <div >
                    </div>
                </div>
           </div>

LinePage.aspx

     <div id="header1" >
                <asp:Label ID="Label2" Class="label_header" runat="server" Text=""></asp:Label>
     </div> 

I need h4 tag value of id line_name_1 if anchor tag of id="line_1" card is clicked. similarily, h4 value of line_name_2 if anchor tag of line_2 card is clicked . which is to be displayed in Text="" of asp_label control.

CodePudding user response:

You can add query strings into your anchor tags:

<a href="LinePage.aspx?text=TheTextToTransfer" id="line_1">YourLinkText</a>

(In the second anchor change the query.) Then access query data in your code-behind:

string text = Request.QueryString["text"];

And assign the value of text as the value in your label in LinePage.aspx.

  • Related