My project is a .net web application containing some boxes on a page with their own data. to load each of the boxes we called a web method (in a web service). we use this approach to load boxes separately(suppose a box has paging within itself and we don't want it causes loading the whole page). my question is about first loading of the page that causes all web methods call and page load slowly. I want to make html of page on server side for first loading of the page and when user open the web page for first time, we send just the made html. I mean similar to merging json data to jtemplate but in server side. or similar what mvc architecture does. or...??? Any Idea ?
Multiple calls to the webservice might slow down the page load. It would be better if we make a single call to the webservice and the service return a dto with data for the boxes in your page.
The simplest way would be to invoke all web methods on the server side as web service calls and send the combined html to the browser.
Better way would be to invoke actual web method implementation (i.e. calling the method code instead of web service invocation) and then combine the html.
Related
Can I have a ribbon button launch an aspx ( asp.net ) page? The aspx page needs to inherit authentication and authorization as the logged in Dynamics user.
You can execute custom JavaScript from a ribbon button allowing you to spin up a new browser window pointing at whatever you like.
To inherit security credentials you need to look at setting up federated authentication across both the CRM server and the custom website hosting the ASPX. As you can probably imagine this isn't a trivial task.
You could also look at dropping your website into the custom ISV folder as was the case with CRM 4. However, this approach has been deprecated in CRM 2011 and AFAIK is therefore no longer supported.
As #Konrad pointed out you won't be able to use the Data Service REST API (OData) from your custom web pages as the service is only accessible from web resources hosted within the CRM environment. Server-side you'll be fine against the Org Service.
If you can get away with doing what you need in a web resource I'd highly recommend it as it's a whole lot less work.
I'm not sure you can do that. A while ago, I put in an iframe that I linked to an outside web page and it worked as supposed to except for connecting to the organization data. I just couldn't make that work (I got impatient, to be honest and didn't try all too hard).
The resolution I deployed in the end was to run a web resource, which was run internally on the server, that communicated the data to an outside service.
I'm assuming that the same behavior will follow if you try to open windows/convey data in to/out from the CRM.
First of all, what are the advantages of Code Behind and Code Beside? I have searched on the internet and found that we use Code Beside in web sites and in ASP and Code Behind while creating WCF. What is the reason behind this?
Thanks in advance
Because WCF service is not a web page. In ASP.NET WebForms you define markup in your web page and code related to markup. When the page is compiled initialization code related to markup is generated and merged with your code to form a single class handling the web page.
In WCF the "markup" contains just declarations. It is just support file for IIS processing which will tell web server which service factory and service type must be used to handle incoming call. Information from markup is not related to your service class and there is no code merge - the code behind service class is complete implementation of the service and can be used even without the markup file which is not true for code beside web pages.
I'm building a system which can create forms during runtime. System is written for WinForms and works well for creation of Windows forms and reports. Forms are written to the database as XML.
Now I want to extend that principle to web domain. On Default.aspx for example I plan to put placeholder and write code for creation of web controls.
The question that bugs me is - how can I open such web page from my WinForms appliaction? I need to open it in default browser and transmit ID to it.
The sequence is this - Design the form, save it to database, open a web page with form rendered on it.
Ok so taking the trival example of saving a form to the DB it will get an ID.
You can then have an ASP.Net page that expects to be passed a param on the QS of formid=1
so
http://yoursite/formbuilder.aspx?formid=1
Within your page you can then check if that id is passed in on the querystring and create the form that way.
To open the browser you can do something similar to this
System.Diagnostics.Process.Start("http://<yoursite>/formbuilder.aspx?formid=1");
I'm a PHP developer who has to work on ASP.net projects and I'm wondering why every page is wrapped in a form. This just doesn't make sense to me.
Also What's with all the hidden input fields especially the "View State" one.
ASP.Net tries to make it so that the programmers can pretend that the web is a stateful platform, and that it behaves like a desktop application. The ViewState is basically a serialized block of the state of the page when it was generated. When the page gets posted back the server side model gets initialized to the values in ViewState, and then the new values from the posted form are applied.
Part of becoming a decent ASP.Net programmer is learning when to use ViewState and not, because the default is to use it everywhere which causes a lot of bloat in the downloaded page.
Every ASP.NET page is wrapped in a <form> element because the entire framework revolves around POST commands.
ASP.NET provides 'web controls' which are object-oriented abstractions of HTML elements (and in some cases, groups of elements) - in your server-side code you can attach commands to various events on web controls (for example, Button.OnClick, TextBox.OnChanged) - the framework wires these up using a combination of hidden fields and generated javascript. The generated javascript typically sets a hidden field few values to indicate (for example) which control triggered the post and the command arguments (if applicable), then submits the form.
ViewState is a technique used by the framework to serialize client state. It's an alternative to using session heavily, trading larger HTML payloads for a lower memory footprint on the server.
Everything in ASP.NET (aspx pages) works off of posting data.
This means that anything you place on the web page with a server-side action will cause a "post back" to itself. The post back contains information such as "what just happened" and some information that helps the web page to maintain state (which web pages don't traditionally do). The view state is part of that task of maintaining state.
If you don't like the way aspx pages try to turn web-pages into forms-style stateful applications, you can try out the ASP.NET MVC framework, which lets the web work as intended!
ASP.NET WebForms engine creates a stateful abstraction over stateless HTTP.
The key object is a server page. Controls fire events that are processed server-side. Controls maintain their states (usually, input values) between requests.
Any time you click a server control, a "postback" request is sent back to the server. ViewState actually contains the data telling the server what control fired the event. That is why there is always a form (and any more forms are not allowed).
I am new to this whole sharepoint and aspx programming. I have developed a sharepoint web part that has a button control. The onclick event is mapped to a method in my web part code. When I click the button the whole page reloads and the web part is rendered again. Is there a way to prevent this reloading of the page? Is there a way to call the function method in the background? Something similar to AJAX.
Thanks,
Jagannath
You can use Ajax, it just requires some sharepoint configuration. Here are a few posts to get you started:
http://weblogs.asp.net/jan/archive/2007/02/26/using-the-ajax-control-toolkit-in-sharepoint.aspx
http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3
Ajax or SilverLight are your only two options for Async operations without a page refresh.
Once you know the tricks needed to get SharePoint and ASP.NET AJAX to work together it's not that difficult.
Here are the steps required:
Ensure the ASP.NET AJAX Extensions are installed on all the front-end web servers (this is not required if you are using .NET 3.5 as the Extensions are included in the Framework)
Update the Web.config file for the SharePoint Application to support ASP.NET AJAX
Ensure any page that is going to use AJAX has a ScriptManager
Use an UpdatePanel or a client-side service call to get updated data and re-render the Web Part
This blog post has some resources from a talk I did on the subject at TechEd Barcelona 2008. These resources should give you the information you need to get started.
http://msmvps.com/blogs/windsor/archive/2008/11/13/teched-emea-resources-and-demos-integrating-asp-net-ajax-with-sharepoint-2007.aspx