Can Page.IsPostBack property be used in Windows forms?? c# [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hi guys I am trying to use the "Page.IsPostBack" in my windows form project. I am aware that this can be used on web pages but can it be used in windows forms as well?
if so will I need to import anything?

No, those are two completely different paradigms. IsPostBack is meant for stateless programming, whereas windows forms is stateful.

Nope. Postbacks are used in web forms. .IsPostBack is not a member of windows forms so there is no way to use it.

Simplified summary:
WebForms needs the IsPostBack property because the form is loaded every time it posts back (traditionally this was anytime a button was pressed, though now AJAX changes that a bit). Because it stored a serialised version of all data in ViewState, you didn't want to reload the data in a lot of cases (this proved to be a huge issue as ViewState massively increased the page data, something for another topic).
WinForms only needs the OnLoad() handler, as the form is loaded once and stays on screen, no matter how many times a button is clicked. You can close and re-open the form, but it is valid to reload the data in that scenario. In your OnClick handler you can decide if/when to reload any data as required.

Related

Hiding or Closing a Windows Form on C# [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have a windows form which have a textbox & a button on it.
I'll show & use this form for filtering some datagrid columns when right clicked their column header.
And this form will be using constantly obviously.
Now I'm thinking,
Should I close it everytime or simply hide & reshow when needed?
Which is the best for performance & memory? Or do you suggest any other thing for this filtering type?
Which is the best for performance & memory?
"Best" isn't a question nor a SMART requirement.
Of course if you just hide the form, it and its contents will stay in memory. This means your application uses more memory, but on the other hand, when you need to show the form again, you won't have to load the entries from the database again - making it appear faster.
If it's a form you really frequently need, I'd just hide and re-show it. See Hide form instead of closing when close button clicked how to do this.
If the app runs very fast, it may be better to close it. If loading is heavy - hide it.

How to refresh multiple screens on a single button click MVC C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Hope everyone is well.
I am dealing with a multiplayer system and having a problem with the real time refresh. I've tried, metatags, JS function:set intervals for a div, Ajax refresh based on success,.... They all work on that particular screen.
So example if Jack, Barney, Nick and Mary are online playing this game.... When Mary plays, her screen will refresh/update divs accordingly.... However on the other 3 player's screens nothing will happen.
I need a REFRESH/UPDATE of a div to take place when a click is made by any user, this refresh/update must happen ON MULTIPLE SCREENS (any user who is on that page must be able to view the most recent and up to date set of data)
If you have any information on how to go about doing this, please let me know! :)
In other words, you need the server to notify clients of events. With ASP.NET, you should use SignalR for that. It uses the modern WebSockets API if available, and gracefully falls back to other techniques like polling in browsers that don't support WebSockets.
You can find a good example of SignalR 2 using with MVC 5 here:
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-getting-started-with-signalr-20-and-mvc-5

Static pages (.html) vs ASP.NET pages (.aspx) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
we are going to develop a media website where we will show current news.
For that we have 2 strategies:
Create window service in C# which will generate static (.html) pages for website (with updated news) as there will be only images and text (no postback or server-side event required) on website and then service will upload affected pages on server.
Create application in ASP.NET (.NET Framework 4.0) and use output caching for few minutes in it (as news updates in every 2-3 minutes).
Please suggest which one from above will be more preferable from performance (or other) point of view in my situation.
Please also suggest if any other strategy may provide me better solution. Thanks.
Making static pages will also prevents user to wait until new page is generated on server,so there is no way,only html can understand either new page or itself is generated again.This will cause user to make an interaction with the page (refresh) to find new results,so the cycle ends.You cannot expect user to know when content is changed.
As long as the content is dynamic in time interval,you should prefer asp.net solution with AJAX requests.You can make this with single page.
DO NOT FORGET that either developing via HTML or aspx or any kind will display your results in HTML output,so unless your page shall use any server content,try asp.net dynamically.
I can also assist code,please verify the specs.
Best Regards
Second one will be nice method
Problem with the first method:
HTML page want to be created each time
Created HTML pages what to be deleted or overwritten each time
Whole page want to be recreated (by using AJAX update can be done faster)
so comparatively second one is the right method.

Converting any Jquery Plugin to .NET Server Control [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
What you should know if you need to convert a jquery plugin to .NET server control (.ascx).
Is there anybody have a good tutorial or would like his ideas what's best and how you should do it?
Check out the following link
jQuery Asp.net Controls by David Taylor
DJ-Jquery Web Controls for asp.net
I don't really think is possible, in general server controls are server side while by design jquery plugins are client side, why would you incapsulate what is already working server side into a server control which renders the same client side code?
There are many issues:
1) Self-registration of scripts and css - any server control should be completely self-contained, so it should be able to ensure its own resources are available
2) Naming container safety (e.g. you can't really hard-code references to server objects, or the code won't be reusable). You can't really get away with using Static client IDs, this would break naming container safety from the get-go. So you need a way to pass references to the client script dynamically.
3) Hooking with asp.net client event model, e.g. to update data passed from the server after partial postbacks, if you want them to work right in UpdatePanels

Is there a concept of session management in Winforms applications? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 months ago.
Improve this question
Today I was asked why we cannot implement state management in Winforms applications like we do in web applications, and I did not know the answer.
Can someone explain why we cannot, or if we can, explain how it works at a high level?
[...] why we cannot implement state management in Winforms [...]
This is an incorrect statement. In fact, we implement session management in every Winforms application, and we are so habitual about doing it that we don't even realise we are doing it.
The very nature of a desktop application is that all the state information you need is available in process memory, and it remains available as long as your application is running.
For example, it you set the value of a string variable to "Hello World", it will retain its value as long as that variable is accessible. Unlike web applications, you don't have to do anything explicitly to retain it. So the correct question might be
Why don't we need to implement session management in a WinForms application?
although I would be stumped by the obviousness of answer.
We can implement state management in Winforms.
Assume you need to access a Winforms control value in another Winforms application by clicking a button on the first form. You can access them by:
declaring public class members and auto implemented properties in the second form.
Set the values of the second form's class members in the first form's button_click event
After step 2, run the code you want to run on button click.
So the class and its members can be used in achieving state management in Winforms application.

Categories

Resources