This is a migrated thread and some comments may be shown as answers.

[Solved] RadMaskedTextBox display problem

1 Answer 280 Views
Input
This is a migrated thread and some comments may be shown as answers.
xiang long
Top achievements
Rank 1
xiang long asked on 19 Jun 2008, 12:29 AM
hello everyone,
I bind RadMaskedTextBox to get the IP address value from database, but it displays the IP value in RadGrid as "123156255255" format, and when i click "Edit", then the IP value display as normal IP format "123.156.255.255".
The following is souce code: 
<telerik:RadMaskedTextBox ID="hostipTextBox" Runat="server" Height="22px"  InvalidStyleDuration="100" 
Mask="&lt;0..255&gt;.&lt;0..255&gt;.&lt;0..255&gt;.&lt;0..255&gt;" 
Text='<%# Bind("HostIP") %>' TextWithLiterals="000.000.000.000" Width="220px" PromptChar=" _" RoundNumericRanges="False"           DisplayMask="&lt;0..255&gt;.&lt;0..255&gt;.&lt;0..255&gt;.&lt;0..255&gt;">
</telerik:RadMaskedTextBox>
I also check the database, the value it saved is "123156255255".
Can anyone tell me how can I make the value that RadMaskedTextBox saved in database as normal IP format, i.e. 123.23.255.255,  and display normal IP format both in RadGrid and in its Edit model?

Thanks
xiangm

1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 19 Jun 2008, 03:02 PM
Hello Xiang,

I tried to duplicate your problem, but was unsuccessful. Are you using a RadMaskedTextBox control in the ItemTemplate and EditItemTemplate of your RadGrid? It sounds to me like you are only using it in the EditItemTemplate, which is why the correct mask would only show up there.

Here is my code, so you can get an idea what I am talking about.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
         
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
            <MasterTableView>                 
                <Columns> 
                    <telerik:GridTemplateColumn> 
                        <ItemTemplate> 
                            <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" 
                                Text='<%# Bind("HostIP") %>' 
                                Height="22px" 
                                Width="220px" 
                                PromptChar="_" 
                                RoundNumericRanges="false"                                 
                                Mask="<0..255>.<0..255>.<0..255>.<0..255>" 
                                > 
                            </telerik:RadMaskedTextBox> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" 
                                Text='<%# Bind("HostIP") %>' 
                                Height="22px" 
                                Width="220px" 
                                PromptChar="_" 
                                RoundNumericRanges="false"                                 
                                Mask="<0..255>.<0..255>.<0..255>.<0..255>" 
                                > 
                            </telerik:RadMaskedTextBox> 
                             
                        </EditItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridEditCommandColumn ButtonType="LinkButton" /> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
   
    </form> 
</body> 
</html> 
 

using System; 
 
public partial class Test : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        var address1 = new { HostIP = "123156255255" }; 
        var address2 = new { HostIP = "192168153100" }; 
        Object[] addresses = { address1, address2 };         
        RadGrid1.DataSource = addresses; 
        RadGrid1.DataBind(); 
    } 
 

I hope this helps. Please feel free to post any further questions you may have, or if you do not feel that your problem has been resolved.

Sincerely,
Kevin Babcock
Tags
Input
Asked by
xiang long
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or