.NET MVC

401

Solutions

299

Contributors

Microsoft’s ASP.NET MVC is a web application framework that implements the model–view–controller (MVC) pattern. As an open-source software, it’s set apart from the ASP.NET Web Forms component, which is proprietary.

Share tech news, updates, or what's on your mind.

Sign up to Post

Looking for some help on searching two fields at the same time.  Currently what I have is a little wonky.  I can filter by first or last name but I am having difficulty doing both at the same time.  Looking at some help in that aspect.  

View
 <p>
        @using (Html.BeginForm("Index", "Members", FormMethod.Get))
        {
            <b>Search By</b> @Html.RadioButton("searchBy", "members_firstname" + "members_lastname", true) <text>First or Last Name</text>
            @Html.RadioButton("searchBy", "members_id") <text> ID</text>
            @Html.RadioButton("searchBy", "members_ssn")<text> SSN </text>
            @Html.RadioButton("searchBy", "members_phone")<text> Phone </text>
            @Html.TextBox("search") <input type="submit" value="search" />
        }
    </p>

Open in new window



	public ActionResult index(string searchBy, string search)
		{
			if (searchBy == "members_id")
			{	int convertedSearch;
				int.TryParse(search, out convertedSearch);
				return View(db.members.Where(x => x.members_id.Equals(convertedSearch)).ToList());}

			if (searchBy == "members_firstname" + "members_lastname")
			{return View(db.members.Where(x => x.members_firstname.Contains(search) ||x.members_lastname.Contains(search)).ToList());}

			if (searchBy == "members_ssn")
			{return View(db.members.Where(x => x.members_ssn.Contains(search)).ToList());}

			else
			{return View(db.members.Where(x => x.members_phone.Contains(search)).ToList());}

		}

Open in new window


This will bring back search will radio buttons. With query options for first or last name as expected.  What I would like is to be able to search for both at the same time.  

if (searchBy == "members_firstname" + "members_lastname")
			{ return View(db.members.Where(x => x.members_firstname.Contains(search) ||	x.members_lastname.Contains(search) || x.members_firstname.Contains(search) && x.members_lastname.Contains(search)).ToList());
			}

Open in new window



This is what I have tried to combine both.  Am on the right track?  Or better yet is there away to do away with the radio buttons and search all fields at the same time?
0
I am the beginner in this technology and its been 8 hours straight and i am not able to figure out the issue, the first thing i am not understanding is about first 3 tags,

soapenv:Envelope
soapenv:Header
soapenv:Body

the request which is generated by C# does not include "soapenv:"
More over the exception "Data at the root level is invalid".
I have tried the other way, directly passing the static data by XML and got the response which means that my credentials and server is working fine.  But now i have to pass values dynamically, so gotta use C# way. Any help will be appreciated and I shall be really grateful. Its getting pain in the a** -_-

Thanks in advance.

The XML request is

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.juniper.es/webservice/2007/">
<soapenv:Header/> 
<soapenv:Body> 
<HotelAvail> 
<HotelAvailRQ Version="1.1" Language="en"> <Login Email="user@mydomain.com" Password="pass" /> 
<Paxes> 
<Pax IdPax="1"> 
<Age>50</Age>
 </Pax> 
</Paxes> 
<HotelRequest>
<SearchSegmentsHotels> 
<SearchSegmentHotels Start="2013-08-20" End="2013-08-22" DestinationZone="1953"/> <CountryOfResidence>ES</CountryOfResidence> 
<Boards> 
<Board Type="AD"/> 
</Boards> 
</SearchSegmentsHotels> 
<RelPaxesDist>
 <RelPaxDist> 
<RelPaxes> 
<RelPax IdPax="1"/> 
</RelPaxes> 
</RelPaxDist> 
</RelPaxesDist> 
</HotelRequest> 
</HotelAvailRQ> 
</HotelAvail> 
</soapenv:Body> 
</soapenv:Envelope>

Open in new window


in C# i made like this:


Open in new window

0
what technologies offer Authentication over Web Services when created with

.NET MVC framework and WebAPI?

And how much os this is provided by the .NET Framework?

Thanks
0
Hi Guys,

I have asp.net mvc application and I added ADO entity from my test database then I changed the connection string to the production database. The database in the production and test environment are identical and everything was working just fine so far.

Today I changed the connection string back to the test environment and all of a sudden I got this error:

"error 0019: Each type name in a schema must be unique. Type name 'RMSmasterHQModel.Cashier' was already "

work around:
I recreate the entity and still the same issue.

Please, help.
0
Dos the error in the attached images simply mean the IntelliSense in Visual Studio has not had the word "packages" added?

Packages not declared
Thanks
0
I opened a demo project from PluralSight, and must assume it compiles okay. But some of the References do not render.

What shall I do for these?

The Target framework is set to .NET 4.6.1

Suggestions?
0
will be using at least Visual Studio 2015 Community Edition.

What are the various windows hotkeys which open windows and generate code?

For example, is it

"prop tab tab"

which generates a template of a property with Get and Set configured?

And what about opening other windows with certain keys?

Please provide me a map for these...

Thanks
0
My model has a field, CloseDate, defined as datetime.

        [Display(Name = "Close date")]
        [DataType(DataType.Date)]
        public Nullable<System.DateTime> CloseDate { get; set; }

Open in new window


It's displayed on my Edit page as follows:

@Html.EditorFor(model => model.TargetedFundingCloseDate)

Open in new window


If I enter or select a date, and click Save, the value is saved to my database. However, when the record is again displayed in Edit, I see the same mm/dd/yyyy placeholder that I did when CloseDate was null; and if I click Save, my originally selected date is saved as null.

Screen shot of CloseDate on Edit.shtml
What can I do to get around this? Have I missed something basic?
0
I have an MVC 5 project with Bootstrap, and a form that relies upon the model for its field content. There are many fields which need to be textareas, to allow up to 255 characters; but I don't want to take up space unnecessarily. Ideally the textarea would begin with a single line, and grow as text is added via data entry (and shrink back as text is deleted).

                <div class="form-group row">
                    <div class="col-md-4">
                        <label>@Html.DisplayNameFor(model => model.FundAgreements)</label>
                    </div>
                    <div class="col-md-8">
                        @Html.TextAreaFor(model => model.FundAgreements, 1, 100, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.FundAgreements)
                    </div>
                </div>

Open in new window


When I had a simple HTML5 form, without Bootstrap, I was able to use the below in $(document).ready for <textarea>, but so far have been unable to modify it successfully to work with Html.TextAreaFor.

 <textarea id="FundAgreements" class="intake-textarea" rows="1" maxlength="255"></textarea>

Open in new window


// Auto resize textarea based on text entered
function resizeTextArea() {
    $(".intake-textarea").keyup(function(e) {
        $(this).height(30);
        $(this).height(this.scrollHeight + parseFloat($(this).css("borderTopWidth")) + parseFloat($(this).css("borderBottomWidth")));
    });
}

Open in new window

0
Hi, I'm using VS2013, C# and asp.net.  
I got a new project and I would like to do this in MVC 4 or 5?  I only developed ASP.net MVC 1.0 long time ago and would like to update my MVC skill.  This will be web application and users are required to log in using their company network credential.
Users are submitting data using this application.  Users will see a series of radio button selection or a Other field to complete then click Next to complete additional form data.  There will be about 20 of these questions for users to complete.  Only one question is displayed to users at a time because each subsequent question form really depends on what users answer on each form.  Depends on what they entered at current form will affect what will be presented for them to complete in the next form.

I'm still trying to decide either to store the data in SP2013 (List?) or in SQL server.   Users will needs lots of analysis reports so not sure what's best to do here.  

Is there a plug in or nuget package for what I'm trying to do here?
Thank you.
0
How can i read file from FileShare. When i change filepath to local machine it works perfect, but when i change it to UNS path to SharedFolder, it wont work. And it throws an error System.IO.Exception

 
 try
            {
                var filePath = @"\\192.168.150.11\Tine Integrasjon\Riversand\Riversand.xml";
                var test = File.OpenRead(filePath);
                FileInfo file = new FileInfo(filePath);
                FileStream fs = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);

                if (!file.Exists)
                {
                    Run(sp, filePath);
                }
                else
                {
                    logger.WriteLine("Det finnes ingen fil å lese fra, sjekk mappen 'Riversand'", DateTime.Now.ToString());
                }
            }
            catch (Exception e)
            {
                logger.WriteLine("Failed to run application.", e.Message + Environment.NewLine + e.StackTrace);
            }

Open in new window


iam getting Exception:  System.IO.IOException " The user name or password is incorrect".

Visual studio is running as Administrator, an user have read /Write permission on SharedFolder.
Iam running my development enviroment on Windows Server 2012 R2, and another VM in same domain with SharedFolder. And Firewall is diabled in all domain.!

If i just paste UNC Path (\\192.168.150.11\Tine Integrasjon\Riversand\Riversand.xml) in FIleExplorer, it opens the file, without any issue on authenticating. But when iam running my Console Application and i try to read the file i get an error : The username or password is inncorrect...
0

.NET MVC

401

Solutions

299

Contributors

Microsoft’s ASP.NET MVC is a web application framework that implements the model–view–controller (MVC) pattern. As an open-source software, it’s set apart from the ASP.NET Web Forms component, which is proprietary.

Top Experts In
.NET MVC
<
Monthly
>