Why web controls does not have sufficient events like windows application? - asp.net

Hai , An asp panel contains only 6 events. if they provide a visibilechanged event it may very useful for me. if it is in windows application ,how easy it is.I dont know why thy are not providing all these.This is same as in the case of gridView, button ,etc.
just think , I have an Iframe in an asp panel and two buttons. In first time it is invisible .Buttons named first and second respectively. Two another pages One.aspx,two.aspx. These two pages contains each text box. When you click on the First button . I want to set the Iframe src="One.aspx" and display "first" in the textbox on One.aspx. as same in the case , when user clicks Second button. How to do this ?

Web technologies work quite differently than Desktop technologies.
Desktop technologies can directly talk to native OS and hence they are functionally more rich.
In case of web technologies, the application runs on a web-browser which is independant of server-side web technolgy and vice-versa. Both the server and the web-browser talk using Http which is stateless transport service.
Some technolgies like Flex, Silverlight and WPF browser applications have gone beyond the browser limitations and they have become much more rich compared to traditional web-apps.
WPF browser apps and Silverlight are bridging this gap very fast.

Er, its quite hard to understand your disjointed sentences, but it sounds like you just want to handle the button clicked event.
In Visual Studio, in design view, double-click the button and it will generate the click handler event for you.

Related

ASP.NET Web Forms and React

I'm new to React, so please bare with me.
I have made a simple ASP.NET Web Forms project that successfully opens a page in React. My next question is, is it at all possible to open a new popup from the React-page with the content of an ASPX-page, and in some way communicate between the 2 pages?
Scenario:We have bought access to a simple layout designer, made with React, that we want to feed JSON with different settings. These settings, however, are currently coming from a ASP.NET Web Forms page (hosting an ASCX control) which is generating the JSON. Is this scenario completely impossible? Maybe we can use a service to communicate between the two, but its important that this 3rd party designer (which through the developer of this, has access to implement custom features, like opening a popup or similar) can open a settings-popup we have created in ASP.NET Web Forms.
If this is too complicated, any ideas would be appreciated to how we can accomplish this. For example, are iframes still a thing? Or are there new technologies that works better? (In case we need to host a page outside the React project, that communicates back).
I hope my explanation is understandable, otherwise let me know, and I'll try to elaborate.
Hope you can help, thank you in advance!
For clarification, we have hired the developers of the 3rd party software to help us implement the solution, React-wise, so I just need to find out what the possibilities are in regards to the integration of the 2 worlds.
be it bootstrap, jQuery + jQuery.ui dialogs, or react? They all should work. however, what you can't do in ALL cases is allow ANY postback in that dialog form you displayed. Once you do a postback- then the page cycle starts and it blows out the dialog form.
And this issue is not really limited to webforms, but that of you now having to avoid post-back when such dialogs are displayed. Of course while web forms are somewhat legacy today, they are VERY nice in how easy it is to wire up controls and their events to code behind.
Needless to say, adopteding one of these frameworks that has all those great dialogs and widgets? They sure are nice, but now it means you having to write ajax calls and avoid post-backs - and that can be a lot of work. So while even jQuery.UI can load a WHOLE different aspx page into a div and pop it up? (and it works VERY well). Well, ok, you now have that cool differnt page as a dialog popup form, but you can't fire any post-backs via standard asp.net buttons and controls when you do this. And as noted, this issue is not really limited to asp.net web forms, but only that webforms obvsilty encouraged a LOT of post-backs with code behind. The amount of round-trips from those post-backs is costly, but HUGE savings in time to write such code with great ease.
You could try a dialog form with a update panel surrounding the controls that do cause post-backs.
So, in web forms, the VERY thing that was you friend and resulted in GREAT ease of coding is now your very same enemy. (that enemy being lots of post-backs and round trips).
So, you have to give up a LOT of code and forms that do postbacks simply can't be shoved and dropped into say some popup dialog form, since that form VERY likely had a lot of post-backs - and they will collapse that dialog and start the round trip process.
As long as you keep the above in mind? Then adopting bootstrap, jQuery.UI dialogs or react should work just fine - but you be spending lots of time writing out ajax calls, and those calls to code behind will NOT have use of the textboxes and controls on the form - since they are sill sitting on the browser + users desktop and do not come along for the ride when you make the ajax calls to the server side code.

Particular ASP.NET Page runs slower than Rest on Server

I am working on an ASP.NET website (not web application) that acts as a data-entry point for a database. We're targeting .NET 4.0. We have a very general page setup: There is a list of items in a gridview, and when the user wants to edit an existing item or add a new one, we use a ModalPopupExtender that holds controls for a data-entry screen. We have put the Extender and all related controls into a single User Control, so that we can easily reuse the these screens.
Everything runs great on my development machine. Fast and reliable.
On the server, one of the pages runs incredibly slow. This page has the User Control with the most child controls. 17 Textboxes, 18 DropDownLists, a TabContainer with 3 TabPanels, 7 Buttons/LinkButtons, and something like 10 Labels.
When you enter the page, it loads slowly. When you click to edit an item (which runs a function in the User Control to populate every control), it takes a good 4 seconds before you see the popup, whereas the other tools with a third of the controls load pretty much instantly.
I get that we're querying a lot of data, so I'm already investigating loading the form dynamically, maybe one quarter of the controls at a time. I think I can do that with [WebMethod]s but am not sure.
It still seems very unusual to me, though, that our server with all the more powerful resources available to it, lags compared to my development box.
Is there anything I should be changing in the website itself, or in IIS on the server, to try and mitigate these slow-downs?

Converting WinForms App to WebForm App

Previously i was working on Windows Form based application in .Net. Now i am developing the same app in ASP.Net.
The issue is, in WinForms, i had functionality which is like this:-
ListView was present in the MainForm. When a user clicks on that ListView, another form was going to pop-up, which is also a WinForm. (For this form i was sending a Bill Object as reference)
In the pop-up form, the user will select a particular Billable Item and click on a button called "Add".(This Billable Item is going to be saved in Bill Object)
When this button is clicked, an event is fired in the MainForm. This event was going to add the Billable Item (the one which user has selected in the pop-up Form) into the ListView using the 'Bill Object', without even closing the pop-up form.
This procedure will continue until the user manually closes the pop-up Form.
My issue is, i do not know how to realize this or make this work in Web Application using ASP.Net with vb in code behind. I am using Content Page.
I know i can use GridView in asp.net, just like ListView in WinForm.
Please give your valuable suggestions.
Thank You,
Mayur
ASP.net was designed to be familiar to WinForms developers which is why you have many of the same control names. In actuality, this is often a hindrance as there are significant differences between many ASP.net webcontrols and their WinForms counterparts.
In addition the page lifecycle that is at the heart of ASP.net webforms is a very different model to what you would be used to with WinForms.
I suggest starting with the official ASP.net learning resources. They're a great introduction to the two main ASP.net approaches:
Webforms: http://www.asp.net/web-forms
MVC: http://www.asp.net/mvc

How to integrate Jquery Mobile with an existing ASP.net WebForms application

I have an existing ASP.net 4.5 webforms application that I want to make into a "WebApp"-like application for mobile browsers.
What I'm mainly interested in is the graphics / sizing / scaling aspect, since the WebForms site works well with mobile browsers already, but it looks ugly and not "mobile" at all.
Reading around, I came across jQuery mobile, which at a glance seems perfect: just including it in my website turns every element of the page "mobile friendly" (fixed page size, big buttons and elements, auto stretching, etc.).
But my initial enthusiasm was short lived: as soon as I tried to use the website, I noticed that while the graphics were perfect, including JQ mobile broke almost all the logic, for example:
DropDownLists stopped generating postbacks
Clicking on LinkButtons stopped working (nothing happens on click)
UpdatePanels broke completely (the ajax calls don't fire anymore)
MultiViews broke completely (they get reset to the initlia View on
every postback)
Am I doing something wrong, or is it just that WebForms and JQuery Mobile are just incompatible?
If they are incompatible, can anyone suggest an alternative to make my website look like a mobile web app (other than re-designing everything by hand that is).
I use asp.net webforms in conjunction with jQuery Mobile and they can work well together. However it takes some forethought and planning, and probably some new ways of doing things compared to the traditional webforms approach. So converting an existing webapp is not as quick and simple as you would like.
Some hints:
If you are using a single aspx page with multiple data-role="page" elements, consider putting all of them within one FORM element so that asp.net postbacks/updatePanels can work.
For linkbuttons, you will most likely need to turn off the default AJAX loading of page links in jQM.
In many cases, instead of using postbacks on controls, use client-side scripts to make async calls via PageMethods in the codebehind, or WebMethods in a WebService(asmx). If you are more comfortable with UpdatePanels, these should still work if you have everything inside a form tag and a scriptmanager within the form tag too.
DropDowns do get restyled by jQM, so you might want to catch the change event in javascript and then either use async calls or fire the postback via javascript.
Here are some other opinions:
JQuery-Mobile and ASP.Net - AJAX or Postback?
How to mix jQuery Mobile and ASP.NET
jQueryMobile in ASP.NET WebForm
If you choose to have Ajax enabled with jquery mobile JQM [which is preferred when using JQM to give the user feeling a native app], you won't have the post back anymore. That is not good because you would lose a lot of built in features like validation controls, built in request validations....
So, one of the options would be using WCF restful service and have it compatible with asp.net (by having this in the web config: serviceHostingEnvironment aspNetCompatibilityEnabled="true"). In this case, you need to mitigate security threats like script injection and cross side request forgery and .... inside with the WCF service as there is no built in request validation.
And now some JQM gotchas:
In order to avoid a lot of surprise, you may have only one page in the DOM by removing previous page from the DOM. This way, you don't need to worry about having multiple items with the same id in the DOM.
The other thing is binding events. if you have a java script in you master page and you have let say a click event to bind, make sure to use one instead of on. otherwise, it behaves unexpectedly.
For the client side validation jquery validation works fine and easy to use and no conflict with JQM.

alert box in asp.net web application

how can i use an alert box in asp.net web application without using javascript with Yes/NO option, much like messagebox in desktop (windows) application.
Thanks
Simple, you can't. That message box object is only for WinForms Development.
You can't create one - although you could make it look like one by using an overlay div and "message box" div. The additional content would need to be controlled on the server so it would require a POST request to the server when displaying and another for submitting the Yes/No click.
Write an ActiveX control?
(Please don't do that.)

Resources