Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Troubles with jquery ui dialog and save method
Message
 
 
À
03/04/2013 13:18:02
Information générale
Forum:
ASP.NET
Catégorie:
MVC
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01569821
Message ID:
01569935
Vues:
22
>>Now it seems to be 'String or Binary data will be truncated message'. Strange again as I only put few characters in the Address field and didn't change anything else. Luckily I think I'll be able to figure out this problem using profiler.
>
>Are you sure that nothing on the browser is padding that value ?

No, not sure at all. I am going to go deeper now into this - how the browser would pad data? Also, do you have an idea why my StringLength(5) condition was breaking for Ext while I didn't even touch it?

Could it be in the way I have my view defined and the Editor Templates?

The view is
@using CardNumbers.Helper
@model CardNumbers.Models.ClientViewModel
  <form id="add-edit-form">
    <fieldset>
        <legend>Client Info</legend>

        @Html.ValidationSummary(true)
       
        <input type="hidden" id="fntype" name="fntype" value="Edit">

        @Html.HiddenFor(m => m.ClientId)
        @Html.EditorFor(m => m.ClientNumber, EditorTemplate.TextBox)

        @Html.EditorFor(m => m.ClientName, EditorTemplate.TextBox)

        @Html.EditorFor(m => m.Client.Address, EditorTemplate.EditBox)

        <div id="ContactsInfo">

            <div id="Contact1">

                @Html.EditorFor(m => m.Client.Contact1)

            </div>

            <div id="Contact2">

                @Html.EditorFor(m => m.Client.Contact2)
            </div>
        </div>

       @* <div id="SaveCancel" class="float-right">
            <button id="btnSave">Save</button>
            <button type="reset" id ="btnCancel" name="Reset">Cancel</button>
        </div>*@
    </fieldset>

 </form>
I think it's simple enough.

The Editor Templates:

TextBox template
<div class="editor-label">
    @Html.Label((ViewData.ModelMetadata.DisplayName??ViewData.ModelMetadata.PropertyName),
        new Dictionary<string, object>
            {                
                { "for", ViewData.ModelMetadata.PropertyName }
            })
</div>

<div class="editor-field">
   @if (ViewData.ModelMetadata.ModelType.IsNumeric())
   {
    @Html.TextBox("", ViewData.TemplateInfo.FormattedModelValue, new { type = "number", @class = "numericOnly"  })      
   }
    else
    {
     @Html.TextBox("", (object)Model,
        new Dictionary<string, object>
            {
                { "id", ViewData.ModelMetadata.PropertyName },
                { "name", ViewData.ModelMetadata.PropertyName },
                { "class", "text-box single-line"},
                { "data-bind", "value: " + ViewData.ModelMetadata.PropertyName },
            })
    }
   
     @Html.ValidationMessage(ViewData.ModelMetadata.PropertyName,
        new Dictionary<string, object>
            {
                { "data-valmsg-for", ViewData.ModelMetadata.PropertyName }
            })
</div>
PhoneInfo template
@model CardNumbers.Objects.PhoneInfo

<div id="PhoneInfo">
    <div class="float-left">
        @* @Html.EditorFor(model => model.Phone, EditorTemplate.TextBox)*@
        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>
    </div>
    <div class="float-right">
        @*@Html.EditorFor(model => model.Ext, EditorTemplate.TextBox)*@
        <div class="editor-label">
            @Html.LabelFor(model => model.Ext)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Ext)
            @Html.ValidationMessageFor(model => model.Ext)
        </div>
    </div>
</div>
And the ContactDetail template
@using CardNumbers.Helper
@model CardNumbers.Objects.ContactDetail

<div class="editor-label">
    @Html.LabelFor(model => model.Contact)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.Contact)
    @Html.ValidationMessageFor(model => model.Contact)
</div>
@*@Html.EditorFor(model => model.Email, EditorTemplate.TextBox)*@
<div class="editor-label">
    @Html.LabelFor(model => model.Email)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.Email)
    @Html.ValidationMessageFor(model => model.Email)
</div>
@Html.EditorFor(model => model.phoneInfo)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform