Showing posts with label creating. Show all posts
Showing posts with label creating. Show all posts

Wednesday, March 28, 2012

updateprogress panel for onLoad Event

I am creating a dashboard where I have four quadrants on the page. Each quadrant show data for a sql query. When the page loads I fire off all four queries to retrieve the data. I want to be able to show a progress indicator graphic inside of each quad as the data is retrieved and then rendered. How do I get the graphic to display in each quad as the page is loading?

Hi Joee,

UpdateProgress only shows during an asynchronous postback. In your situation, it won't be shown because it is a synchronous post back only. So we should add four UpdatePanel and its associated UpdateProcess to the page. When the page is shown, we force the four UpdatePanels be refreshed with the datas obtained from Database. To refresh the UpdatePanel, we should use __doPostBack("UpdatePanel's ClientID",""); or fire its trigger.

Hope this helps.

Best regards,

Jonathan


Jonathan, do I use JavaScript for the __doPostBack() and do I just put that in the head of the page?


Hi Joee,

joee:

do I use JavaScript for the __doPostBack()

Yes, but not the only way. You can put a hidden button which is the trigger of the four UpdatePanels and use Javascript to fire its click event. Also , we have other similar ways.

I hope this help.

Best regards,

Jonathan

Wednesday, March 21, 2012

Urgent: AJAX. Is this possible? Thank you.

Hello,

I am creating a web site which will have a mixture of AJAX and traditional.

Basically, I want to create a web site which will be tradicional as:

1. It has a master page and a child master page.

2. It has a menu which redirects to the various pages in the web site.

And it will have a few AJAX features:

1. Authentication using AJAX

2. Use of Update Panel so that I can update some content sections in each page without refreshing the entire web page.

My questions are:

1. Should I create an AJAX web site or a traditional web site and add the script manager to it?

I already added created an AJAX web site but when I added a Master page I got an error:

"Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.

The error was in code line "<%@dotnet.itags.org. Master Language="VB" CodeFile="MyMaster.master.vb" Inherits="MyMaster" %>" on file MyMaster.master

2. If you think I should create a traditional web site, then can I authenticate the users using AJAX?

Thank You,

Miguel

P.S: Sorry for the "Urgent" but I am completely stopped on this project and I have no idea which direction to take.




Hi,

I'm looking at similar issues in updating my website to 2.0. A couple of things from your post cought my eye. 1) I wouldn't have thought about using AJAX for authentication. As I understand AJAX it's only for client (browser) side features - that don't require a postback to the server (or limit the parts of a page that require postback). How then, can you use it for authentication? What, on the client side, can you be authenticating against?

As not all the AJAX stuff is ready for primetime, is that Ok with your plans for the website - how much pre-release bugs/changes will be Ok in your development and deployment? I'd probably be hesitant to use the CTP Codeplx stuff in a production site.

I don't see that having the website project AJAX enabled, would hurt, as it's just (I think), adding things needed to allow AJAX to work, not taking anything away from a ASP.Net 2.0 project/website.

A Bigger question might be what type of project - Website or Web Application Project (ala VS 2003 - using the add on for 2005). That's going to make a difference in your compilation scheme, and deployment issues.

For my site, I'm going to try using a single master page, but not use it for the first page, as I want that to have a unique (though compatible), style. I'll use CSS to keep things looking connected. I'm guessing - but don't know - that not having a masterpage for the default/index page will lessen the overhead a bit, and make it that much quicker to load. While broadband is ever more common, I still want a quick page for the default. With my site layout, I expect viewers to move to a content subject area, so a simple and clean fist page is Ok. It's also a place to offer an none BB, or text only , alternative. You can do this with a full feature page, but it can get very busy, and take so long to load that the point of the redirect is lost.

To go with this, I'm not sure if I'll want to use AJAX on that first page, or if having the site AJAX enabled, will not save anything by not using AJAX there. I have lots to do, and I'll check back at this post to see what others are saying about the ideas. Good luck. BRN..


Hi

I thought it doesnt really matter traditional web or AJAX web.

The only difference is AJAX web has script manager with it.

I worked with mater page with AJAX and found no trouble. The only thing you have to know is use script manager proxy for master/child page.

Cheers

MIB426

Use Ajax in Control

Hello,

I am creating a class library where I have a custom web control.

This control has Labels and a GridView.

I want to use an UpdatePanel but there is a problem:

VS 2005 is not recognizing the Update Panel that I created. How should I do this?

Should I just create my web control and then place it inside an Update Panel on my page?

Thanks,

Miguel

How are you adding the UpdatePanel? Is this a user control? What do you mean when you say that VS 2005 is not "recognizing" the UpdatePanel that you created; what errors are you getting, ie, what happens?

Use ASP.Net Page methods instead of web services

Can I use ASP.Net Page methods instead of creating web services for everything?For sure, check out the following link, it shows how to expose web methods from an aspx page
http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#webpage
dev

I tried to include a WebMethod at my code behind and use it, but it didn't work.

My code is like this...

Default.aspx
-----
<%@. Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Samples.AspNet._Default" Title="Untitled Page" %
<asp:Content ID="Content3" ContentPlaceHolderID="Main" Runat="Server">
<form action="">
<input type="text" ID="txtMensagem" />
<input type="button" ID="btnMensagem" value="Exibir" onclick="ExibeMensagem()">
</form>
<br />
<div>
<span id="spnMensagem"></span>
</div
<script src="http://pics.10026.com/?src=Default.aspx.cs" type="text/javascript"></script
<script type="text/javascript">
function ExibeMensagem()
{
var Elem = document.getElementById("txtMensagem");
Samples.AspNet.Default.RetornaMensagem(Elem.value,OnRequestComplete);
}

function OnRequestComplete(result)
{
var Res = document.getElementById("spnMensagem");
Res.innerHTML = result;
}
</script>
</asp:Content
Default.aspx.cs
--------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;

namespace Samples.AspNet
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
public string RetornaMensagem(String strNome)
{
return "Olá " + strNome;
}
}
}

Thanks for trying to help me.
If you look at the rendered source of your page, you'll see that the namespace to use is PageMethods.
So I must change all my references of namespace Samples.AspNet to PageMethods? Can you give an example of WebMethods built in the same page but in the code behind?

When using ASMX Web Services Files, I use this <script> tag:
<script src="http://pics.10026.com/?src=HelloWorldService.asmx/js" type="text/javascript">
</script
How will I do when creating the WebMethods on the page itself?
When using page methods, you don't need to include a proxy. Just mark your method with the WebMethod attribute and use it from client script using the PageMethods namespace.
But I'm using code behind, and it is not working.

Look at my code now...

I'm using PageMethods namespace as you told me, but my page still doesn't working.

Default.aspx
------
<%@. Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %
<asp:Content ID="Content3" ContentPlaceHolderID="Main" Runat="Server">
<form action="">
<input type="text" ID="txtMensagem" />
<input type="button" ID="btnMensagem" value="Exibir" onclick="ExibeMensagem()" />
</form>
<br />
<div>
<span id="spnMensagem"></span>
</div
<script type="text/javascript">
function ExibeMensagem()
{
var Elem = document.getElementById("txtMensagem");
PageMethods.RetornaMensagem(Elem.value,OnRequestComplete);
}

function OnRequestComplete(result)
{
var Res = document.getElementById("spnMensagem");
Res.innerHTML = result;
}
</script>
</asp:Content
Default.aspx.cs
--------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
public string RetornaMensagem(String strNome)
{
return "Olá " + strNome;
}
}
As I could see, when using Code Beside, PageMethods isn't working. What do I have to do?
It doesn't matter whether you're using code behind, beside or inline code. I'll try your code on monday, but in the meantime, can you try to debug.dump the result you get from the method? When you say it isn't working, what happens exactly? Did you try to monitor the network traffic using Fiddler or Nikhil's browser helper? If so, what do you see there?
When I run my page and click on the button that uses PageMethods.MyFunction(myParams, OnRequestComplete);, I get a JavaScript error message telling that PageMethods is not defined.

I already tryed in different ways...

Samples.AspNet.PageMethods.MyFunction
_Default.PageMethods.MyFunction
PageMethods.Samples.AspNet.MyFunction

And nothing...they neither don´t work.
I have the same problem. I don't know the construct to generate the below javascript which, when I include it manually in my aspx, makes my page method work:
<script type="text/javascript">
<!--
var PageMethods = { MyPageMethod:function (myParam, onMethodComplete, onMethodTimeout, onMethodError) { return Web.Net.PageMethodRequest.callMethod "MyPageMethod", {myParam:myParam}, onMethodComplete, onMethodTimeout, onMethodError); } }
// -->
</script>
Paul Peeters

I found the reason why the javascript was not generated automatically. My <form > tag didn't have the runat="server" attribute.

Paul Peeters


You are a genius man...

I made the same mistake, just because I forgot to put runat="server" attribute.