I have a simple web application where the user inputs three integers into a form and receives the sum as a result.
My question is this: I'd like to have the actual sum value not appear until the user has Submitted. Meaning, when the page is opened up, the ViewBag just displays nothing. And then after submission, the ViewBag content appears. Is it possible for me to do this with the current code I have?
ViewBag.Title = "Index";
<!-- HTML form with "Post" method initiated. -->
<form action="" method="post">
Enter the 1st Number: <input id="firstInt" name="firstInt" type="text"value="0" /><br />
Enter the 2nd Number: <input id="secondInt" name="secondInt" type="text"value="0" /><br />
Enter the 3rd Number: <input id="thirdInt" name="thirdInt" type="text"value="0" /><br />
<input id="Submit" type="submit"value="submit" />
<input id="Reset" type="reset"value="reset" /><br /><br />
Sum = @ViewBag.result
publicclass HomeController : Controller
// GET: Home// Integers initiated in the index parameters.public ActionResult Index(int firstInt = 0, int secondInt = 0, int thirdInt = 0)
// Calculates sum of the three integers, and then sends result to the View.int sum = firstInt + secondInt + thirdInt;
ViewBag.result = sum;
ViewBag.Title = "Index";
Enter the 1st Number: <inputid="firstInt"name="firstInt"type="text"value="0"/><br/>
Enter the 2nd Number: <inputid="secondInt"name="secondInt"type="text"value="0"/><br/>
Enter the 3rd Number: <inputid="thirdInt"name="thirdInt"type="text"value="0"/><br/><inputid="Submit"type="submit"value="submit"/><inputid="Reset"type="reset"value="reset"/>@if (ViewBag.result != null)
<p>Sum = @ViewBag.result</p>
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I have a GridView with a buttonfield column that I am using to edit and save the value of records. The problem I am having is that in the Grid's Row Command event I want to change the button's text from "Edit" to "Save" but my code below doesn't work. Can anyone see what I'm doing wrong?
i saw a article that global.asax is not there in asp.net core rather a concept called middleware there. i just like to know where global.asax has been removed from asp.net core and why middleware comes in core ?
what kind of advantages is there in middleware ?
if anyone knows the reason please guide me. thanks
Typically you need to consider reading at why did Microsoft want to shift from a bloated global handler, to a microservice-like as-needed middleware structure for the startup handler. You can start here, ASP.NET Core Middleware | Microsoft Docs
Secondly, if you have used global.asax, you know that it is tightly packed with the services that ASP.NET provides, everything is already there, it doesn't matter whether you handle it or not. Almost everything is loaded, unless you ignore importing and loading the assembly. Whereas in the middleware, you load items and attach them to the application. You remove, or add how things go around. The best benefit being, you can rearrange them as needed and you can even add your own custom middleware before ASP.NET Core's middleware — which I am not sure was allowed in global.asax.
Finally, since the framework was written to be cross-platform and thus it had to be written in a way that it can reflect the design pattern for such projects.
what kind of advantages is there in middleware ?
Also, the term middleware is just a term used for something can acts in the middle. It is nothing new, or special. It just means, that you can now shift the modules, include more, change the sequence, block a few modules to be loaded (on demand) and much more.
You should consider tweaking around a bit with the Startup class in ASP.NET Core.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
Can someone point me in the right direction on how to do the following?
I need to create a small desktop application that uses FileSystemWatcher to look for file creation. When a file has been detected, it uploads the file to a server (Web API). So far so good.
Here comes the problem: The file(s) need to attach themselves to the 'page' the current user is on.
A user creates a 'New Page' on our website, fills in some information and then imports files that our FileSystemWatcher detects. Somehow the Web API need to find what session the user is on and attach the files to this session and then display the files/images on the current 'page'.
My idea is to add another cell to the user table in the database called "CurrentSession", that holds a uniqueidentifier (pointing towards the PageId). But this Id needs to be cleared if the user leaves the page, closes the browser, disconnects, log-out and so on. It's vital that the files do not attach themselves to the wrong page.
Am I over thinking this? Or is there a better way to achieve this?
But I think, you can definitely maintain the "CurrentSession" unique identifier on client (website page) as well and send this along and validate with the one stored in database. This way you do not need to take care of different ways the user is moving away.
The problem is that the files need to go to a specific page and not a specific user.
A user can have thousand of pages, that's why the files should only be transferred IF the user is on a specific page. If they are doing anything else on the website, then the CurrentSession should be null, and the file transfer application will inform the user about it.
So the fail-safe is that if there's no active 'Page' on the customer that is trying to upload files, the application will inform the customer to go and create it and be Active on the Page.
Guess this has to be done by using a service to check for user activity or something...
That would have been nice.. the problem is that the device(s) the client use for image/file -transfers, usually save the files with things like guid names in folders that can contain thousand of other files.
For the user to select the file(s) (between 4-30 files) the device just transferred, in a folder with 1000's of other files with obscure file names, will probably not be ideal. Seeing how many clients are old and selecting the wrong file could be a disaster.
The files are not the issue here, the issue is the "page". The thing is, one user can easily have 20,000 pages. That's why I wanted a solution that can check the CurrentID of the page the user is on.
But agreed, the easiest solution would have been to have a File Upload button on the page, and have the user select the files, but the way the systems are setup, that'll never work.
Correct, there can be multiple devices dropping images into predefined folders (these devices are being controlled and setup by other companies, so we don't have much control over them).
A normal workflow would be:
1. A client creates a 'New Page' on our website. Supplies some details. 2. The client then starts the 3rd-party software and from there select "Transfer File(s)" 3. These files are saved in predefined folders, our small desktop application picks them up and sends them to a web service.
It's safe to assume that the files the client selected to transfer from the 3rd-party software should be attached to the current Page they created on our website.
Sadly enough, we can't in any way change the naming convention and in some cases not even the destination folder (a few of these devices create new sub folders after xxx number of Mb or random number of files).
The problem is to figure out what page they are on, and how to clear that PageID from the "CurrentPageId" when the client is no longer working on that page.
Hey, I', looking for some implementation advice. I am creating this ASP.NET MVC page for quizzes that each course may have a different number of questions with 4 choices. I would like to send the questions to my view as my Model, and by submitting the form, my controller endpoint receives the Id of the questions and selected answers.
Can you please give me some tips that how to send such information to my controller using the sample code I wrote in the following?
All you have to do is to create a few roles like Administrator, User, Customer. Then add users to those roles. The web.config in each folder will ensure that only people with that specific role can get in.
Dear friends Iam new to Asp.net i want to deign one repeater template post based that show me data from databse data may be only text data may be image with text data may be vedio may be only image. so please guide me or give solution
I think you need to try a little bit harder yourself first, rather than asking for such general help. If you search online for "asp.net repeater examples" you will find plenty of help to get your started.
Well, the best thing to do when stuck on any problem is to first try to solve a simpler one. SO I suggest you follow some of the simple examples you can find on the Internet to get a better understanding of how to use the repeater control. You should then be able to make a start on what you want to do, and can come back and ask with some specific problems if you still have any.
No - it might be easier to be given an answer, but better is to learn for yourself. Also, while it might be easier for you, it would be harder for others who volunteer their time to help on these forums.
Last Visit: 31-Dec-99 18:00 Last Update: 24-Sep-23 6:43