I'm writing an aspx to let users check the filename and create a file with that name
the url is
/sites/usitp/_layouts/CreateWebPage.aspx?List=%7b74AB081E-59FB-45A5-876D-
284607DA03C6%7d&RootFolder=%3bText=%27SD_RMDS%27
how can I parse the parameter 'Text' and show in the textbox?
<div>
<asp:TextBox id="Name" runat="server" />
</div>
the aspx text box is this, I tried
<asp:TextBox id="Name" runat="server" text=<%$Request.QueryString['Text']%>></asp:TextBox>>
but it didn't work
anyone can help me out?
To get the value for the http get Parameter:
string testParameter = Request.QueryString["Text"];
then set the Textbox Text
Name.Text = testParameter
Also its strongly suggested to not take Content directly from the url as malicious content could be injected that way into your page. ASP offers some protection from this, still its considered a good practice.
If you want get text value from Querystring you need to use:
var text = (string)Request.QueryString["Text"];
Then you can bind it to Text property of TextBox Name:
Name.Text = text;
Update: You can initialize you server controls values only on PageLoad event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With