Monica Shiralkar

Ranch Hand
+ Follow
since Jul 07, 2012
Cows and Likes
Cows
Total received
8
In last 30 days
0
Total given
0
Likes
Total received
12
Received in last 30 days
0
Total given
47
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Monica Shiralkar

That is coming fine now after I have put a null check. Now a new issue has come that is it shows the if statement in the response itself.

This is the code that I have changed:



It shows response as this and shows even the if statement in the response:
if(model!=null) {
1 Richard Thomas
2 Tom Mathews
3 Ronald Walter
}

How can I avoid the if statement to print in the reponse?
3 weeks ago
I create a view from which user can enter value an option from text box and based on the value of option entered by the user, data from the model will be displayed on the view. This works fine if I used 2 views. One for entering the text box option and other for displaying the results. However if I try to to this in the same view, it gives object reference not set error. This is because the model is available only when user enters the text box value and before entering the value itself it will give object reference not set. How can I achieve this using single view?

The code which works fine using 2 views:

Index.cshtml





HelloAction.cshtml







HelloController.cs







Employee.cs


This is the URL using which I run it on local:

http://localhost:57538/Employee/Index



The above code works  but how to achieve the same using a single view instead of 2 views?

Thanks

4 weeks ago
I will remove the view bag and replace it with returning model object from the controller. I think this should solve the current problem.
4 weeks ago
I wrote a sample .net MVC code for my learning. On running the code it should open a text box from which user can enter option1 or option2. If user selects enter option1 it should display the data from first JSON. If the user enters option2, it should display the data from second JSON. It works. The only problem is that the code displays one of the options by default even before the user enters option1 or option2.


Given below is the code for Hello1Controller.cs where hello action is called from the click of button from view code.





Given below is the code for index.cshtml (the view for Hello1Controller). From here on click of button the user selection goes to the controller method named ActionResult



This code is working fine. The only problem is that the code displays one of the options by default even before user enters option1 or option2. I tried to remove index method to solve this but it did not work. How can I remove this default data displayed even before user enters a value?

I understand that Viewbag should be avoided in this example.I will do that correction once I am done correcting the problem I have listed in this post.

thanks




4 weeks ago
thanks . yes that is an overhead.
4 weeks ago
Thanks. I was thinking of using JQuery to reduce the amount of code to call the API from the HTML page.
1 month ago
Yes I had seen the port configured in project properties and that it can be changed. I was thinking that the port will be configured to some default 5 digit number. Eg  44344  and it can be changed to some other port but this 5 digit default port is different for different people that is something I didn't understand. I am not talking about the port which is changed to but talking about the default port (before changing it from properties)
1 month ago
I so far checked it looks like no fixed number different for different people trying to run it. But for all cases it is a 5 digit number. I will check further. Thanks
1 month ago
I had already checked this but when I run a .net application by clicking ctrl F5 on visual Studio it opens http://localhost:44844 like in tomcat it runs http://localhost:8080
1 month ago
I know that in tomcat when we run any application , by default it runs on 8080 port. However when I run a .net application , the port it shows on localhost has not been a fixed one. Is there no default port like 8080 for tomcat? Also in tomcat the logs comes in tomcat catalina lib.Where do I see the logs in case of .net application which runs on IIS?

thanks
1 month ago
I know HTML and want to learn CSHTML. How different is CSHTML from HTML?

thanks.
For my sample application I need to display a JSON with albums songs detail.  User shall enter textbox with albumn name and on clicking search button it shall display all songs from that albumn. I think I can call API controller for this purpose which takes a GET request with albumn name param and returns JSON with list of songs. I think I can use JQuery for calling the API controller. Is it fine to do this way?
1 month ago
When we use both API controller and MVC controller in same project, then what should be each of these be used for in the same project? Should API controller there be used only for where fetching of JSON is required to be shown on the front end and in all other cases we should be using MVC controller in the same project?
1 month ago
Thanks.  Instead if ViewBag which other way should be used?The example which I am trying in my sample application is to read JSON data from the controller and show on the UI in a grid. I read that API controller is for such kind work. So I should change my MVC controller to api controller. What do I have to use repository for?
1 month ago
Is model tied to database always or model means from wherever the data comes from? Can I simply have such code in the controller to get data from the model.



dynamic modelData= MyModel.getModelData();

// code to pass modelData in the view

1 month ago