0

Hi

I am trying to pass value of textbox from Default.aspx to Default2.aspx through a link. I am using VS2008.
Here is my Default.aspx code

<body>
    <form id="form1" method="get" runat="server">
    
        <asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

        <br />
        <br />
        <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>

        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
<br />
        [B]<a href ="Default2.aspx?&name=<% =TextBox1.Text%>" >Link</a>[/B] </form>
</body>
</html>

And I am trying to use this code to display the value on Default2.aspx

<body>
    <form id="form1" runat="server">
    <center>
      <%
      string Name = Request.QueryString["name"];
      %>
      <h1>Happy Birthday [B]<% Response.Write(Name); %[/B]></h1>
      <h3>May the next

      years be as good!</h3>
    </center>

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </form>

</body>

Can any one help me displaying the name of user on Default.aspx.

Thanx to all in advance

Regards

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by shakeb@techwave
0

You can't do this using hyperlink because value of TextBox1.Text property is empty when a page is requested first time. Use LinkButton/Button/Image button and set PostBackUrl property.

...
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

        <br />
        <br />
        <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>

        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
<br />
         
    <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/Default2.aspx">LinkButton</asp:LinkButton>
....
...
<center>
      <%
      string Name = Request["TextBox1"];
      %>
      <h1>Happy Birthday <% Response.Write(Name); %></h1>
      <h3>May the next

      years be as good!</h3>
    </center>

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
....

Edited by __avd: n/a

0

That was a good article i think you got your answer from that thread .!!
if not then explain your requirement again.
Regards
Shakeb Khan

0

Use javascript function OnClick on Link that take value from Text box And also redirect to the page
use this idea or any other id of creating java script function.
I have not tried yet but i hope help full for you

function OnClickLink()
{
var txt= Document.getElementbyid(<%ControlID%>).text
var url="yourpage.aspx?Name=txt

/////
//////
logic
////
///
return url
}

With Regards
Shakeb Khan

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.