Using WPF controls in a background or ASP.Net environment - asp.net

I have noticed that some WPF controls have some decent effects available to them (drop shadow, reflection etc), and was wondering if it was possible to use these WPF controls solely for their available effects?
For example, I have an image manipulation library that resizes and letterboxes disparate sized images but I would like to add drop shadow effects to the resulting images. The WPF image control has this effect available, but how easy is it to use in an environment where there will never be a GUI (console app or ASP.Net library/handler for example).
Thoughts?
Cheers
Moo

You can use them, yes. The only problem is that you have to use them within STA threads, which you probably can't count on happening automagically (e.g., response threads in ASP.NET are MTA).
I'm using WPF controls in a windows service app. I just have to transition to an STA thread before I do my rendering.

Take a look at RenderTargetBitmap. You could do whatever with your WPF component, then render it as a bitmap, and then use that bitmap on your ASP page.
I'm not sure that is the best way of doing it though. Is Silverlight out of question 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.

ASP .NET server control vs. HTML control

At the moment, in my team, there is a conflict when deciding to use HTML control or ASP .NET server control.
For instance, in order to implement a grid view list that supports reordering, we have two options:
Use HTML controls (ul, ol) and jQuery sortable. By using this approach, we can use the markup and style after slicing PSD and implement it rightaaway. We can fetch data by using jQuery ajax.
Use ASP .NET control like Telerik Grid (http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx). Using this option, we have to change style of server control to match the design.
Considering performance and secutiry, please help me figure out which option is better?
Thanks in advanced.
#batto
telerik grid will wonderful you only not think for only this time . May be in future you need many enchantments in your project at that time you really need to use that feature's . So from my view you use Telerik controls .
For only display purpose Jquery grid is better option, it will increase the performance.
HTML control is a compromise between traditional ASP.NET programming and web control and it has a limited object-oriented interface. We usually use HTML control to have a smooth HTML code that will be generated and sent to the browser
If you want a powerful control, choose web control over HTML control!
It hope it helps you.
I would go with a server control. I would probably just use a
You have the ability to do what ever you want with them. If you want to do sorting using jquery then it should not be too different than how you sort ul's. If needed I can provide a sample. You also have the power of the server. If you tie other events such as add or remove then you will want the server control. Its a bit easier to pass data back and forth.

How to embed a SilverLight control in ASP.NET control (user or custom)

We have a ASP.NET web application written in VB.NET where we build content programmatically during the Init event.
We make extensive use of user controls, building them on the fly, and I now want to start including SilverLight content.
Is there an easy way of embedding a SilverLight application in a control, and then instantiating the whole thing in code, in the same way as you'd programmatically add ordinary ASP.NET controls to a page?
The SilverLight component itself works fine when added to a page using the <object> tag but I really want to be able to reuse it elsewhere in code.
Since I'm expecting use of SilverLight to increase in our application, and the asp:Silverlight control seems now to be deprecated, I'm looking for an alternative way of wrapping the content.
Thanks for any pointers.
You can make your own version of the deprecated Silverlight control - all it has to do is emit the appropriate <object> html during its Render event. This is a really straight forward 5 minute task to roll one of these up.

Why web controls does not have sufficient events like windows application?

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.

ASP .NET confusion - server controls

I have read through the information in this question: Controls versus standard HTML but am still rather confused.
The situation was I was asked to do a web project where I made a wizard. When I was done with the project everyone asked why I had used an <asp:Wizard...>. I thought this was what was being asked for, but apparently not, so after this I was led to believe that server controls were just prototyping tools.
However, the next project I did my DB queries through C# code-behind and loaded the results via html. I was then asked why I had not used a gridview and a dataset.
Does anyone have a list of pros and cons why they would choose to use specific html controls over specific server controls and why? I guess I'm looking for a list... what server controls are okay to use and why?
EDIT:
I guess this question is open ended, so I'll clarify a few more specific questions...
Is it okay to use very simple controls such as asp:Label or do these just end up wasting space? It seems like it would be difficult to access html in the code behind otherwise.
Are there a few controls that should just never be used?
Does anyone have a good resource that will show me pros and cons of each control?
Server Controls Rely on ViewState, Restrict Flexibility
Server controls were powerful tools to introduce WinForms developers to web development. The main benefit that Server Controls provide is a sense of statefullness and an event-driven development model. However, the state of web development has been maturing since the introduction of WebForms and server controls, which as a whole are being challenged with an increasingly critical view.
The main issue with Server Controls is that they try to abstract the behavior of the web too much, and in doing so, rely on ViewState data and server resources to perform their magic. ViewState data, when used excessively, can severely bloat the size of your page, resulting in performance problems.
Now it is possible to opt out of ViewState, but by then it probably is better to simply resort to regular HTML controls.
With HTML controls, you have precise control over the content of the web page and you have greater flexibility in what behaviors you want on your web page. Server controls offer limited client-side flexibility and force a lot of work to be performed on the server that can easily be performed in the browser with a good JavaScript framework.
Is it okay to use very simple controls such as asp:Label or do these
just end up wasting space? It seems
like it would be difficult to access
html in the code behind otherwise.
If you need to access the control in server side code, use a server control. If not, don't.
Are there a few controls that should just never be used?
Not in my (mid level) experience. The Wizard control, once you know how to use it, works as advertised (imagine coding all the features yourself, then do the math). I've used it and it resulted in a smooth and functional multi-page sign up form with intermediate saving of data.
Does anyone have a good resource that will show me pros and cons of
each control?
I do not, but I'd recommend using the right control for the right situation. Study the differences between a Repeater and a GridView, for example, and use the best choice for your needs.
There of course are alternatives. For one, MVC is gaining momentum. Personally I have not yet committed to learning it. As far as interactive forms and AJAX goes, many .NET devs opt to use JQuery for any validation and any AJAX (UpdatePanels being easy to use and horribly inefficient), with JSON as the transport mechanism to the server side.

Resources