ItIntern3's Profile User Rating: -----

Reputation: 6 Worker
Group:
Active Members
Active Posts:
89 (0.09 per day)
Joined:
14-July 10
Profile Views:
4,702
Last Active:
User is offline May 15 2013 04:05 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Honda
Dream Kudos:
0
Icon   ItIntern3 is coding in .NET

Posts I've Made

  1. In Topic: MVC View not passing Data to Controller on Postback

    Posted 14 May 2013

    Thank you for your help, sorry for my late reply, but I have solved the problem. When I first called the view method from the controller (I was lacking the [HttpGet]) clause in front of my controller code. I was also calling the view incorrectly as my code
    return view()
    
    should have been
    return view(model)
    
    passing the view an empty model allowed me to populate the model as the user input was entered. When the user clicked the submit button, the model was appropriately passed to the controller with the clause
    [HttpPost]
    
    before the signature. The entire signature of the controller is seen below:

     [HttpPost]
            public ActionResult TutorSignOut(ModelType model)
    
    


    I did not have to use the
    @using (Html.BeginForm())
    
    method listed above.

    Thanks all for your time!
  2. In Topic: MVC View not passing Data to Controller on Postback

    Posted 12 Jan 2013

    If I pass in a "#" symbol into the form action the view still does not return the view model back to the controller.

    Here is the entire view code:

    This may help to diagnose something?

    @model LearningServicesWebApp.Models.TutorSignInSignOutModel
    @{
    
    }
    
    @Html.ValidationSummary()
    
    
    @if (IsPost && @Model.WeeklySession == true && @Model.signedOut == true) @*This is executed on the post back and I am suspecting something in this if statement is rendering the view model unreadable by the controller.*@
    {
        <h2>Reschedule Your Weekly Session</h2>
        <p>
            Would you like to schedule another session at the same time next week? If the same time is desired, click yes.            
        </p>
        <form action ="#" method="post">
        <table>
            <tr>
                <td><input type="radio" name="occurNextWeek" value = "true" checked = "checked" />Yes</td>
            </tr>
    
            <tr>
                <td>Change Session time next week (ex: 11:50):</td>
                <td><input type="text" name="RescheduleSessionTime"/></td>
                <td>@Html.ValidationMessage("RescheduleSessionTime", "*")</td>
                <td><input type="radio" name="RescheduleAMPM"/>AM <input type="radio" name="RescheduleAMPM" value = "PM" checked = "checked"/>PM</td>
    
            </tr>        
        </table>
        <table>
            <tr>
                <td><input type="radio" name="occurNextWeek" value = "false" checked = "checked"/>Do not reschedule session</td>
            </tr>
        </table> 
        <input type = "submit" value = "Submit"/>  
        </form>        
    }
     @*If the session is not weekly, sign the user out*@
    else if (IsPost && @Model.WeeklySession == false)
    {
           <p>
                You have been signed out of your session. Thank you. 
           </p>
    }
    
    else @*This bit of code is executed when the view is first called*@
    {
        <h2>Sign out from your session</h2>
        <form action ="#" method="post">
        <table>
            <tr>
                <td>SessionID: </td>
                @if (IsPost)
                {               
                    <td>
                        <input type="text" name = "SessionID"  value = "@Model.SessionID" size="10"/>                    
                        @Html.ValidationMessage("SessionID", "*")
                    </td>
                }
                else
                {
                    <td>
                        <input type="text" name = "SessionID" size="10"/>                    
                        @Html.ValidationMessage("SessionID", "*")
                    </td> 
                }
            </tr> 
        </table>
        <input type = "submit" value = "Submit" />  
        </form>                  
    }
    
    
  3. In Topic: Using DatePicker and jQuery with MVC

    Posted 31 Jul 2012

    I have been able to get the date picker running.

    Here is the code I used in my view:
        @Html.LabelFor(model => model.EndDate)
        <div class = "editor-field">
            @Html.HiddenFor(model => model.EndDate)
        </div>
    
    


    And the references I added to the Layout.cshtml (located in the shared views folder):
            <link href="@Url.Content("~/Content/jquery-ui-1.8.22.custom.css")" rel= "Stylesheet" type="text/css" />
            <script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
            <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.custom.min.js")" type="text/javascript"></script>
    
    
    


    I was able to download the datepicker widget from the link to the jQuery site (in my previous post).

    Even though I am satisfied with this solution I would like to know why my other attempts (listed in previous post) are not working correctly.

    Now I just need to figure out how to pass the dates from the view back to the controller..
  4. In Topic: Substring : razor/HTML or Entity Framework Issue?

    Posted 27 Jul 2012

    Quote

    Well DateTime is exactly that, a Date and a Time. You should just insert a DateTime.Now value (generated from the database of course) into that field and then you can use the DateTime formats to output the value you need.


    Alright I can certainly do that. I'll just have to alter the column in my SQL database to be datetime rather than time. I did not know if razor's ability to format data inside the view when I was creating my db. Thanks for your advice.

    Again, I am still baffled by this ApplyInEditMode = true statement (namespace: System.ComponentModel.DataAnnotations):
    [DisplayFormat(DataFormatString="0:d", ApplyFormatInEditMode=true)]
    public DateTime Date { get; set; }
    
    


    I understand that the DataAnnotations class is used to validate data that comes from the user on the view, but I haven't the slightest clue what this does...Can anyone give me a concise/understandable synopsis of the msdn page?
  5. In Topic: Substring : razor/HTML or Entity Framework Issue?

    Posted 27 Jul 2012

    Thanks a lot! And I did not mean for time to be a duration--In the database it is type time (as in time of day), but I did not see a type time in C#. I more or less made it of type TimeSpan to make visual studio happy. I suppose I could make it a datetime in C# and use your .ToString() method in razor to format it.

    As you can tell I am a total newbie.

My Information

Member Title:
D.I.C Head
Age:
21 years old
Birthday:
April 27, 1992
Gender:
Location:
Reading, PA, USA
Interests:
Computer architecture, Programming, .NET and Java Eclipse Development
Full Name:
Mark
Years Programming:
3
Programming Languages:
C#, C++, VB, Java, Pascal, BASIC, SQL

Contact Information

E-mail:
Click here to e-mail me

Friends

Comments

Page 1 of 1
  1. Photo

    D.Mulroy Icon

    17 Sep 2010 - 05:01
    Repping PA ^_^, I live in York heading of to Mansfield Uni for CS Fall 2011
Page 1 of 1