Hi @Gary Taylor
First, you want to use the <input> tag to pass a string to another site/app. Do your requirements transfer the value from one project to another? For example, the input value of Project1/Webform1 .aspx is passed to the input of Project2/Webform2.aspx?
Then I can provide you with two methods:
1.Via Querystring
Add "runat="server"" to make this control a server control.
<input id="input1" runat="server" type="text" value="Test" />
This way you can handle this control in aspx.cs.
Next, we make the URL of the page to be sent and the value to be sent into a URL with QueryString for transmission.
string url;
url = "https://localhost:44394/WebForm2?value=" + input1.Value;
Response.Redirect(url);
Then we can get the QueryString via Request.QueryString.
input1.Value = Request.QueryString["value"];
Here's the full code:
Webapplication1/WebForm1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is WebApplication1/WebForm1.aspx
<input id="input1" runat="server" type="text" />
<asp:Button runat="server" ID="button1" OnClick="button1_Click" Text="Submit" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void button1_Click(object sender, EventArgs e)
{
string url;
url = "https://localhost:44394/WebForm2?value=" + input1.Value;
Response.Redirect(url);
}
}
}
Webapplication2/WebForm2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is WebApplication2/WebForm2.aspx
<input type="text" id="input1" runat="server" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
input1.Value = Request.QueryString["value"];
}
}
}
2.But this method will cause the value to be leaked, and you can also do this by using the sqlcommand database operation method.
Best regards,
Qi You
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.