我有一个站点,用户可以在其中输入一些单行到描述字段,稍后将其添加到创建的工作文件夹中。
我的问题是,如果他们在描述字段中输入的文本包含空格,那么当我从.cs页面调用时,它仅将文本从开头移至该空格。我想要用户输入的整个值。
例如:“这是说明”结果:“此”
Default.ASPX页面:
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td> </td></tr>
<tr>
<td>
<span class="SectionHeader">Beskrivning
<asp:CustomValidator ID="CustomValidatorDescription" runat="server"
ControlToValidate="TextBoxDescription" EnableClientScript="False"
onservervalidate="CustomValidatorDescription_ServerValidate"
ValidateEmptyText="True" ForeColor="#DD0000">
</asp:CustomValidator>
</span><br />
<asp:TextBox ID="TextBoxDescription" runat="server" MaxLength="150"
Width="562px" CssClass="textinput" TabIndex="4"></asp:TextBox>
</td>
<td align="left">
<asp:ImageButton ID="ImageButton4" runat="server" BorderStyle="None"
BorderWidth="0px" CausesValidation="False"
ImageUrl="~/images/help_icon_off.png" CommandName="4"
oncommand="ImageButton_Command" ToolTip="Visa hjälp för fältet" />
</td>
</tr>
</table>
<asp:Panel ID="Panel4" runat="server" CssClass="tip" Visible="False">
Är den (metadata) text som kommer att visas i uppdragskatalogen i filutforskaren
i Windows.<br />
Denna information går att ändra i efterhand.
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
我从ASPX文件中发布了整个内容,以防万一你们需要检查.cs使用的其他内容,例如“ UpdatePanel4”或“ CustomValidatorDescription”
Default.ASPX.CS:
protected void ButtonCreateDir_Click(object sender, EventArgs e)
{
string description = TextBoxDescription.Text;
然后,我需要使用“说明”。我也有2个下拉列表和另一个传递给.cs页面的文本字段,尽管这些字段上没有空格,但工作正常。
事实证明这是一个非常简单但棘手的修复程序:)
cs页面将触发一个Powershell脚本,该脚本位于用户在页面上填写的数据的本地位置。由于当您调用Powershell脚本时其空白,因此您需要在“之间”。这解决了该问题:
string vartDescription = "'" + TextBoxDescription.Text + "'";
因此,正是Powershell脚本被称为“错误”。:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句