如何在文本框中显示字符串或单词的确切格式? [英] how to display an exact format of string or words in textbox?.

查看:95
本文介绍了如何在文本框中显示字符串或单词的确切格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在文本框中显示字符串或单词的确切格式?







this是我的代码如下。



我写的时候:



你好世界这个

这是一篇测试文章。



我希望我写的东西应该以那种格式显示。但是在显示txtArticles中它会显示的是连续的这个。



你好世界这是一篇测试文章。

< br $> b $ b

<

how to display an exact format of string or words in textbox?.



this is my code below.

when i write:

"hello world this
this is a test article".

I expect that what i write should display in that format.but what happen is that in display txtArticles it display continous like this.

"hello world this is a test article".


<

<div style="margin-left:200px; width: 756px;">
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Label ID="lblNewsFeed" runat="server" Text="News Feed:" Font-Bold="True"

                Font-Size="Larger" ForeColor="White" style="font-size: 35pt" Width="240px"

                Font-Italic="True"></asp:Label>
            <br />
            <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Image ID="imgNewsFeed" runat="server" Height="102px" Width="116px"  /> <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:FileUpload ID="FileUploadNewsFeed" runat="server" ForeColor="White" />
            <br />
            <br />
            <asp:Label ID="lblTitle" runat="server" Text="Title:" Font-Bold="True"

                Font-Italic="False" ForeColor="White" style="font-size: 15pt"></asp:Label> <br />
            <asp:TextBox ID="txtTitle" runat="server" Width="570px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please Write the Title!" Font-Bold="True" Font-Size="15pt" ForeColor="#FFFF99" style="font-size: 13pt" ControlToValidate="txtTitle" ></asp:RequiredFieldValidator>
            <br />
            <br />
            <asp:Label ID="lblArticles" runat="server" Text="Articles:" Font-Bold="True"

                ForeColor="White" style="font-size: 15pt"></asp:Label> &nbsp;&nbsp;&nbsp;<asp:Label ID="lbl_Save" runat="server" Font-Bold="True" Font-Size="15pt" ForeColor="#FFFF99" ></asp:Label>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please Write the Article!" Font-Bold="True" Font-Size="15pt" ForeColor="#FFFF99" style="font-size: 13pt" ControlToValidate="txtArticles" ></asp:RequiredFieldValidator>
            <br />
            <asp:TextBox ID="txtArticles" runat="server" TextMode="MultiLine" Wrap="true"

                Height="350px" Width="570px" CssClass="NoresizeTextBox" ></asp:TextBox> <br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:Button ID="btnClear" runat="server" Text="Clear"

                BackColor="#669999" BorderColor="#009999" Font-Bold="True" Font-Italic="False"

                ForeColor="White" OnClick="Clear_Click" CausesValidation="False" />

            &nbsp;&nbsp;&nbsp;<asp:Button ID="btnPost" runat="server" Text="Post Article"

                BackColor="#669999" BorderColor="#009999" Font-Bold="True" Font-Italic="False"

                ForeColor="White" OnClick="ArticlePost_Click"/>

        </div>



>





< br $>



>




<<pre lang="xml">asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                        <HeaderTemplate >
                            <table style="border-left-color:#75A4A4; border-left-style: solid; border-left-width: 2.5px;  border-top-style: solid; border-top-width: 2.5px; border-top-color:#75A4A4;" width="570" >
                        </HeaderTemplate>

                        <ItemTemplate>
                        <tr style="border-right-color:#669999">
                            <td>
                            <asp:Label ID="lblDate" runat="server" style="border-bottom-color :#719F9F; border-bottom-style: solid; border-bottom-width: 2.5px;"  Font-Size="11" Font-Bold="true" ForeColor="white" TextMode="MultiLine" Rows="0" Enabled="False" ReadOnly="True" BackColor="#669999" Wrap="True" Height="18px" Width="570px" BorderWidth="0px"  Text='<%#Eval("Date") %>' /> <br />
                            <asp:Label ID="lblTime" runat="server" style="border-bottom-color :#719F9F; border-bottom-style: solid; border-bottom-width: 2.5px;"  Font-Size="11" Font-Bold="true" ForeColor="white" TextMode="MultiLine" Rows="0" Enabled="False" ReadOnly="True" BackColor="#669999" Wrap="True" Height="18px" Width="570px" BorderWidth="0px"  Text='<%#Eval("Time") %>'/> <br /> <br /> <br />
                            <asp:TextBox ID="txtTitle" runat="server" Font-Names="Times New Roman" Font-Size="25px" ForeColor="white" Font-Bold="true" Rows="0" TextMode="MultiLine" Enabled="False" ReadOnly="True" BackColor="#669999" Wrap="True" Height="70px" Width="570px" BorderWidth="0px" style="text-align:center" CssClass="NoresizeTextBox" Text='<%#Eval("Title") %>'/> <br />
                            <asp:ImageButton ID="ImageButton1" runat="server" BackColor="#669999" ImageUrl='<%#Eval("ImageName", "~/NewsFeedImages/{0}") %>' Height="150px" Width="150px" style="margin-left:210px; cursor:pointer"  OnClientClick="return LoadDiv(this.src);" Title="View Image"  />
                            </td>

                        </tr>

                        <tr style="border-right-color:#669999;" >
                            <td class=" comment more"  <asp:TextBox ID="txtArticle" runat="server" style="text-align:left;" ForeColor="white" Font-Size="13"  Wrap="true" TextMode="MultiLine" Enabled="true" ReadOnly="True" BackColor="#669999" Width="570px" Height="100px" BorderWidth="0px"  CssClass="NoresizeTextBox"  Text='<%#DataBinder.Eval(Container.DataItem,"Articles").ToString() %>'></asp:TextBox>
                            </td>
                        </tr>

                        <tr>
                            <td style="border-bottom-style: solid; border-bottom-width:2px; border-bottom-color: #75A4A4;">
                            <br />
                            </td>
                        </tr>
                        </ItemTemplate>

                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString25 %>"
                        SelectCommand="SELECT [Title], [Articles], [Date], [Time], [ImageName] FROM [NewsFeedTbl] ORDER BY [id] DESC">
                    </asp:SqlDataSource



>


>

推荐答案

ConnectionStrings:DatabaseConnectionString25 %>\"
SelectCommand=\"SELECT [Title], [Articles], [Date], [Time], [ImageName] FROM [NewsFeedTbl] ORDER BY [id] DESC\">
</asp:SqlDataSource
ConnectionStrings:DatabaseConnectionString25 %>" SelectCommand="SELECT [Title], [Articles], [Date], [Time], [ImageName] FROM [NewsFeedTbl] ORDER BY [id] DESC"> </asp:SqlDataSource



>


>


Dear god what is with all the &nbsp; ’’s (btw none of that code is relevant from what i can tell), since this is HTML in order to do a line break you need to add




Dear god what is with all the &nbsp; ''s (btw none of that code is relevant from what i can tell), since this is HTML in order to do a line break you need to add


"hello world this
this is a test article".





To get this format to look like this in HTML you would do



To get this format to look like this in HTML you would do

"hello world this <br />
this is a test article".





Tah dah



However you specifically say \"Textbox\". In html, a textbox (input type=\"text\") is a single line input, I think what you are looking for is a text area.





Tah dah

However you specifically say "Textbox". In html, a textbox (input type="text") is a single line input, I think what you are looking for is a text area.

<textarea style="width:400;">
 "hello world this
this is a test article".

 </textarea>







By using a text area you could simply type your content in as is and it would show as desired.



Or you could use the <pre> element as well.






By using a text area you could simply type your content in as is and it would show as desired.

Or you could use the <pre> element as well.

<pre>
 "hello world this
this is a test article".
 
</pre>


这篇关于如何在文本框中显示字符串或单词的确切格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆