TK1
TK1

Reputation: 396

Confirm dialog jquery MVC3 Helper methods

I am creating a confirm dialog box in one of my MVC views. Basically I wawnt to display the exact same information in the dialog before the information is submitted to the server.

In my view I have something similar to the following:

@Html.TextBoxFor(m => m.Prop1)
@Html.TextBoxFor(m => m.Prop2)

<input type="button" id="btnSubmit" value="Submit" onclick="submitFunction();" />

<div id="divConfirmDialog" title="Confirm Dialog">
    @Html.DisplayFor(m => m.Prop1)
    @Html.DisplayFor(m => m.Prop2)
</div>

In document.ready function, I initialize the divConfirmDialog as a jQuery dialog. I open the dialog on the submit button click event.

I do not see the changes that I have made to the textboxes inside my dialog. How would I go about in seeing those changes when the dialog opens?

Upvotes: 0

Views: 393

Answers (2)

Khalid
Khalid

Reputation: 194

Yes, Here is another way to do this,

<div id="divConfirmDialog" title="Confirm Dialog">
  @Html.DisplayFor(m => m.Prop1,new {@class="prop1-display"})
  @Html.DisplayFor(m => m.Prop2,new {@class="prop1-display"})
</div>

Upvotes: 0

Jason P
Jason P

Reputation: 27012

The DisplayFor() method renders text for the value of the property when the page loads.

I would change the html to something like this:

<div id="divConfirmDialog" title="Confirm Dialog">
    <span class="prop1-display"></span>
    <span class="prop2-display"></span>
</div>

Then in your submitFunction(), you can move the values from the textboxes to the spans.

Upvotes: 2

Related Questions