地址显示 [英] address display

查看:79
本文介绍了地址显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我让用户在我的数据库中输入一个地址.哪个控件更适合在我的页面上漂亮地显示该地址?
我需要以下结构:

名称,
city-1010,
状态,
国家.

Hi,

I have the user enter an address in my database. Which control is better to display that address beautifully on my page?
I need below structure:

name,
city-1010,
state,
country.

Can you please help me?

推荐答案

如果您使用HTML编码存储地址,我认为div最好代表它.

您是将地址存储在数据库的单列中还是将其拆分为多列?

[更新]

感谢更新.因此,如果您将其存储在单列中,则用`` ''(空格)分割地址并收集地址行(如果出现这种情况,将有4条)
然后,只需在每行之后添加<br/>,然后将整个字符串放入div.
I think div will be best to represent it IF you''re storing address in HTML Encoded.

Are you storing address in single column in DB or you have spitted it to multiple column ?

[update]

Thanks for the update. So If you are storing in single column then split the address with '' ''(Space) and gather address lines(in case of you there will be 4)

Then simply add <br/> after each line and put the whole string in div. Do you think it makes sense to you ?


srinivasvempa写道:
srinivasvempa wrote:

我应该使用asp.net控件例如label,textbox ....用于显示该地址

i should use asp.net control like label,textbox.... for displaying that address



根据您在页面中的需要调整/设计控件&将下面的代码写在后面的代码中.



Align/Design your controls based on your need in you page & write the below code in the code-behind.

string Details = "Name;City;State;Country";
string[] arDetails = new string[4];
char[] splitter  = {';'}; //Define deliminator based on the original string
arDetails = Details.Split(splitter);
for(int x = 0; x < arDetails.Length; x++)
{
    switch(x)
{
    case 0:
    lblName.Text = arDetails[x].ToString();
    break;
    case 1:
    lblCity.Text = arDetails[x].ToString();
    break;
    case 2:
    lblState.Text = arDetails[x].ToString();
    break;
    case 3:
    lblCountry.Text = arDetails[x].ToString();
    break;
}
}


是的,可以根据需要对代码进行更改.


Do changes in your code based on your need.


是的,div是个不错的选择,它的权重很小,但是如果您了解html设计和css(因为我在边距和填充方面感到困惑) .我使用表创建了示例代码.因为在表格中,我们很乐于处理并能够正确对齐,并且还具有适当的浏览器兼容性.
Yes div is good option, it si light weighted but if you have knowledge of html designing and css (because i confused in margin and padding). i created the sample code using table. becaus in tabel we are esy to handle and able to align properly and also have proper browser compatibility.
<table width="600px" style="vertical-align:middle">
          <tr>
              <td>
                  <asp:Label runat="server" Text="Name" ID="lblName"></asp:Label>
              </td>
              <td>
                  <asp:TextBox runat="server"  ID="txtName"></asp:TextBox>
              </td>
              <td>
                  <asp:Label runat="server" Text="City" ID="lblCity"></asp:Label>
              </td>
              <td>
                  <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
              </td>
          </tr>
          <tr>
              <td>
                  <asp:Label runat="server" Text="State" ID="lblState"></asp:Label>
              </td>
              <td>
                  <asp:TextBox runat="server" ID="txtState"></asp:TextBox>
              </td>
              <td>
                  <asp:Label runat="server" Text="Country" ID="lblCountry"></asp:Label>
              </td>
              <td>
                  <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
              </td>
          </tr>
      </table>




希望对您有帮助.




Hope it will help to you.


这篇关于地址显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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