Showing posts with label searching. Show all posts
Showing posts with label searching. Show all posts

Monday, March 26, 2012

Intellisense / Element unknown errors

So I did some searching around and didn't find any solution to my problem, so I figured I would go ahead and post it.

I think the problems are both related to one another.

#1 - Intellsense does not work - typing <atlas: doesn't have anything appear.

#2 - I have errors in my source view for <atlas:ScriptManager runat="server" /> that element ScriptManager is not a known element.

The problem seems to be that my files are stored on a remote IIS server and I'm connected via a mapped drive to that location. If I copy the web site to my local drive, then everything works great - put it to the server that error comes up.

It doesn't bother me that much, as I normally work in Source View so switching to design isn't the end of the world, but the lack of Intellisense for me is driving me nuts as I'm trying to learn Atlas and how it works.

Thanks to anyone who has any suggestions.

RichardYou can add the Microsoft.Web.Atlas.dll assembly to the Visual Studio toolbox on your local machine. That will make make the controls available to all projects. Seethis post for more information.

-- Karsten
Thanks for the reply. I actually ran across that post and added them to the toolbox. I see them in the tool box, I can drop and drag them to page - but the system still doesn't know what the tags mean.

I will try it again when I get back into the office today.

Richard

Saturday, March 24, 2012

Invoking post back on page load (an easy question - but I couldnt find the answer!)

What I want to do is very easy, so I'm very frustated to have to ask this on the forum - but I've been searching the net for 2 days now and couldn't figure out the answer in a nice "Atlas" way of doing things.

The behaviour I want is exactly what pageflakes.com does when you go their home page: Display a "loading" message while the data is being loaded.

Icanput an UpdatePanel with my data controls in it.

Icanput an UpdateProgress control to show the "loading" message.

What Idon'tknow, is how to make it so that the client-side page will invoke a postback immidietly after loading, i.e. call the BindData() function on the server-side page.

I would prefer a declerative solution to this, or at least, a very short Javascript code (but I'm not too picky - first priority is to get the basic functionality :-) )

Little help?

Is the question unclear? or is it not as easy as I thought? Google does it, pageflakes does it, so I know it's possible...

This is what I have so far.

The javascript pageLoad() function runs properly after loading, and it does indeed call the server (and is capable of returning data to the page, I checked with js alerts)- but the label in the updatepanel doesn't change.

In addition, I received the wierdest error -must have <head runat="server"> You might notice I've added the runat=server to the header, though it still doesn't work.

Default2.aspx

<%

@.PageLanguage="VB"AutoEventWireup="false"CodeFile="Default2.aspx.vb"Inherits="Default2" %>

<

html>

<

headrunat="server"><title>ddd</title>

</

head>

<

body><formid="MainForm"runat="server"><atlas:ScriptManagerID="sm"runat="server"EnablePartialRendering="true"/><atlas:UpdatePanelID="UpdatePanel1"Mode="Always"runat="Server"><ContentTemplate><asp:LabelID="Label1"runat="server"Text="Label"></asp:Label></ContentTemplate></atlas:UpdatePanel></form><scriptlanguage="javascript">function pageLoad()

{

GetServerTime();

}

function GetServerTime()

{

var message ='';var context ='';

<%=sCallBackFunctionInvocation%>

}

function ShowServerTime(timeMessage, context) {

alert(

'The time on the server is:\n' + timeMessage);

}

function OnError(message, context) {

alert(

'An unhandled exception has occurred:\n' + message);

}

</script>

</

body>

</

html>

Default2.aspx.vb

Partial

Class Default2Inherits System.Web.UI.PageImplements ICallbackEventHandlerPublicFunction GetCallbackResult1()AsStringImplements System.Web.UI.ICallbackEventHandler.GetCallbackResultMe.Label1.Text ="Binded, at last"Return ("The server time is " &Date.Now.ToString)EndFunctionPublicSub RaiseCallbackEvent1(ByVal eventArgumentAsString)Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEventEndSubPublic sCallBackFunctionInvocationAsStringProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

sCallBackFunctionInvocation = _

Me.ClientScript.GetCallbackEventReference(Me,"message","ShowServerTime","context","OnError",True)EndSub

End

Class
Sorry, I havent got an asnwer for you, but Im trying to do the same thing.

I have built a query screen that connects to one of my web services and nicely brings back a list of results using atlas, then when you click on one of the results it loads the details page which then shows you the full details of the selected item.

The thing is when the details page is being loaded I have to call 4 web services to get the required data back, and this can take anything upto 8seconds to do. During this time the first screen is just locked whilst the details page is being built in the background.

What i want is the details page to show straight away - but empty, and my UpdateProgress to show a nice ticking loading sign.

As you said, PageFlakes has a nice example of this working, but I cant seem to replicate it.

I have tried putting my server side code in the page load event, then setting the trigger for the updatepanels to page load, but it doesnt seem to like this.

if you find an answer let me know!

stuart

Eureka !Idea [Idea]

With the help ofMatt Gibbsfrom Microsoft (ScottGuthrie refered me to him) I managed to do it.

Matt's answer to my question was a little different from how I ended up doing it, so I'll show both.

First, my crude way... The trick was not to useICallbackEventHandlerbutIPostBackEventHandler (I didn't even know it existed before Matt told me).

ASPX page:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default4.aspx.vb" Inherits="Default4" %><html><head runat="server" > <title>ddd </title></head><body> <form id="MainForm" runat="server"> <atlas:ScriptManager ID="sm" runat="server" EnablePartialRendering ="true" /> <atlas:UpdatePanel ID="UpdatePanel1" Mode="Always" runat="Server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> </atlas:UpdatePanel> <atlas:UpdateProgress ID ="UpdateProgress1" runat="server"> <ProgressTemplate> Loading... </ProgressTemplate> </atlas:UpdateProgress> </form> <script language="javascript"> function pageLoad() { GetServerTime(); } function GetServerTime() { var message = ''; var context = ''; <%=sCallBackFunctionInvocation%> } function ShowServerTime(timeMessage, context) { alert('The time on the server is:\n' + timeMessage); } function OnError(message, context) { alert('An unhandled exception has occurred:\n' + message); } </script> </body></html>


This is the code behind:
 PartialClass Default4Inherits System.Web.UI.Page'Inherits System.Web.UI.WebControls.WebControlImplements IPostBackEventHandlerPublic sCallBackFunctionInvocationAs String Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load sCallBackFunctionInvocation = _Me.ClientScript.GetPostBackEventReference(Me,"message")' Me.ClientScript.GetCallbackEventReference(Me, "message", "ShowServerTime", "context", "OnError", True)End Sub Public Sub RaisePostBackEvent1(ByVal eventArgumentAs String)Implements IPostBackEventHandler.RaisePostBackEvent System.Threading.Thread.Sleep(2000)Me.Label1.Text ="Binded, at last"End SubEnd Class


Now, this is what Matt wrote, I see how it's better because it's easier to apply later to any application, but I couldn't create it:

1) create a custom control that inherits from WebControl, let's call it Loader

2) In the code for Loader, have it override the Render method and call GetPostBackEvent reference. It should render out clientside script for the pageLoad function that contains the result of the call to GetPostBackEventReference.

3) The Loader control should also implement the IPostbackEventHandler interface. In the RaisePostBackEvent method call DataBind on the page.

4) Now you can use the control on your page to have the UpdatePanel refreshed when the page loads.


Here is your sample packaged as a custom control.

The Page:

<%

@.PageLanguage="C#" %>
<%@.RegisterTagPrefix="my"Namespace="Samples" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<scriptrunat="server">
</script>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
</head>
<body>
<formid="form1"runat="server">
<div>
<atlas:ScriptManagerID="sm"runat="server"EnablePartialRendering="true"/>
<atlas:UpdatePanelID="UpdatePanel1"Mode="Always"runat="Server">
<ContentTemplate>
<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>
<atlas:UpdateProgressID="UpdateProgress1"runat="server">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</atlas:UpdateProgress>
<my:Loaderrunat="server"/>
</div>
</form>
</body>
</html>

And the custom control:

using

System;
using System.Data;
using System.Configuration;
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;

namespace

Samples {
publicclassLoader : System.Web.UI.WebControls.WebControl,IPostBackEventHandler {public Loader() {
}protectedoverridevoid Render(HtmlTextWriter writer) {
writer.Write("<script type=\"text/javascript\" >\r\n");
writer.Write("function pageLoad() {\r\n");
writer.Write("alert(\"waiting\");\r\n");
writer.Write(this.Page.GetPostBackEventReference(this));
writer.Write("}\r\n");
writer.Write("</script>\r\n");
}publicvoid RaisePostBackEvent(string eventArgument) {
Label label =this.Page.FindControl("Label1")asLabel;
if (label !=null) {
label.Text ="updated at last";
}
}
}
}
Well done - that has helped me a lot. I got it all working with the user control setup.

I just found out (late, huh?) that search engine spider bots will not be able to "see" the information on any page that uses this, because this uses post backs.

If there's no way to do this and still have the search engines find it, I'll have to give it up. Pitty - this was a very nice UI solution.


I just found this thread - how do I keep the page from posting back in a loop ? It does in fact do a postback after page_load has fired, but it keeps doing it...
It shouldn't be doing it. Go over the code again, see if you can debug it. If not, post it and we'll take a look.

@.BitShift:

The problem might be that you moved the Loader control within the UpdatePanel?? I did that for another reason and I got exactly what you described.

Here is the problem I'm facing:

Yes the sample code that Matt provided does work, however, I want to move my Loader control into the UpdatePanel, so that the first it renders it does the AsyncPostback, and then on the second render it display the real control that I want to load. This avoid the need for triggers and everything in centralized in my Loader control. I too thought this would be easy, but alas not. :(

here is what I have (simplified):

<asp:UpdatePanelID="UpdatePanel1"UpdateMode="Conditional"ChildrenAsTriggers="true"runat="Server">
<ContentTemplate>
<cc1:LoaderID="Loader1"ReportPath="/Analysis Reports Test/Report1"runat="server"/>
</ContentTemplate>
</asp:UpdatePanel>

CodeBehind of Loader.cs:

protectedoverridevoid Render(HtmlTextWriter writer)
{
if (!bPostback)
{
writer.WriteLine("Loading...");
writer.WriteLine("<script type=\"text/javascript\" >");
writer.WriteLine("Sys.Application.add_load(" +this.ClientID +"_Load);");
writer.WriteLine("function " +this.ClientID +"_Load() {");
writer.WriteLine(this.Page.ClientScript.GetPostBackEventReference(this,""));
writer.WriteLine("}");
writer.WriteLine("</script>");
}
else
{
this.Controls[0].RenderControl();
}
}bool bPostback =false;
publicvoid RaisePostBackEvent(string eventArgument)
{
System.Diagnostics.Debug.WriteLine("Postback from : " + eventArgument);
bPostback =true;
MyCustomControl c =new MyCustomControl();
this.Controls.Add(c);
}

When I do this, I lose the AsyncPostback of the UpdatePanel, it does a full page postback. I have to explicitly set the AsyncPostBackTrigger even though it is a child control and the ChildrenAsTriggers="true"?!?

Even at that I am still having another issue, that my page has mulitple of these loaders and all UpdatePanels should be triggered only once. Unfortunately this is not the case. I have the UpdateMode set to Conditional however with the AsyncTrigger it still appears to trigger multiple updates. With 2 UpdatePanels and Loader controls, I get 3 postbacks:
1) Loader2
2) Loader1
3) Loader2

Any helpwould be greatly appreciated.

Perry


I got this problem also, and it's been a long time this thread gone unanswered.

Could somebody gives me exact explanation about how the postback sequence in favor of MS AJAX? It seems to me it got mixed up and the order is different on web form without AJAX.

regards,

Eriawan

Wednesday, March 21, 2012

Is it Possible in ASP.NET - Search Engine Friendly AJAX ?

Hi All,

I am searching for the Search Engine Friendly AJAX Development in ASP.NET from approx last few days, I have searched over the MSN, Google and Yahoo and MSDN Network too, But I am unable to find any topics about the Search Engine Friendly Development using the AJAX / .NET.

I have came across to a pagehttp://www.telerik.com/products/aspnet/controls/ajax/overview.aspx where I have seen that this company is offering Search Engine Friendly AJAX Controls. The fact is that I don't want to buy this component.

But I am looking forward for the help from the Microsoft Team ( Other Developers Too ) that they must have start a topic on Search Engine Friendly AJAX Development, I have to develop around 20,000 pages using the AJAX technology in .NET, I have seen that Search Engine Friendly AJAX Developoment is possible using the PHP using URL rewrite method. But I am looking this kind of development in the .NET.

Nowdays the SEO (Search Engine Optimization) is the major part before developing any website, so my consideration to achieve this task in .NET, I am sure that MS must have given some kind of technique to achieve this kind of task. But I am unable to locate that topics, If any body is aware about this kind of topics then please help me.

Thanks in advance.

you can do url rewriting using asp.net as well using an HttpModule. Further, using Extender-type programming is a good way to ensure backward-compatibility for folks w/o javascript enabled (including search engines. . . ). The idea would be something like this...

You have a control (e.g. <asp:HyperLink) that renders as an anchor tag. You build it 'normally' to do whatever you would w/o ajax, then use javascript controls to override the default functionality with something more ajaxy (e.g. postback-less update).


you can check out an ASP.Net 2.0 solution for urlrewriting ... the site ishttp://pietschsoft.com/blog/post.aspx?postid=762


Considering that when developing Ajax solutions you still have to program to the least common denominator. IE: User has java disabled in their browser. Naturally, one could just rely on the default behaviors of Ajax and related components but often you will find it just leaves a page's functionality useless when it goes into normal postback mode.

However, you can display different options to crawlers by checking the "Context.Request.Browser.Crawler == true" {display this}; thus effictively you can have the logic of the Ajax page work just like you would want. I use this technique myself mainly because I got tired of links to things like profiles etc from being indexed and running a dynamic site there is no way to include all those entries in a robots.txt ...


I've personally been struggling with "accessible" ajax links for a while

You have a control (e.g. <asp:HyperLink) that renders as an anchor tag. You build it 'normally' to do whatever you would w/o ajax, then use javascript controls to override the default functionality with something more ajaxy (e.g. postback-less update).

Exactly the solution.

To postback from <asp:HyperLink> I typically use a hidden variable and postbacks that, using onclick="_doPostBack..." in the js "click" event for the href. I have an article on how to do that.

http://www.aspcode.net/articles/l_en-US/t_default/ASP.NET/ASP.NET-2.0/Ajax/ASP.NET-AJAX-formally-Atlas/Accessible-Ajax-calls_article_449.aspx