Showing posts with label implement. Show all posts
Showing posts with label implement. Show all posts

Wednesday, March 28, 2012

ASP.NET Ajax Timer

Greetings,

i want to implement ajax timer so it will update an updatepanel every five seconds based on a certain codition so i try the following:

<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>

</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="UpdateTime">
</asp:Timer>

in the code behind i write the folowing:

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToLongTimeString();

}
protected void UpdateTime(object sender, EventArgs e)
{
if (new Random().Next(0, 4) == 1)
{
UpdatePanel1.Update();
}

}

so what i notice that every five seconds the tick event will happen and the updatepanel1 will be updated regardless of the condition that i implement it in the UpdateTime method ,what is logic since the tick event happens.

so how can i solve this problem??

your help is highly appreciated

best regards

I tested your codes in Visual Studio .Net 2005 with Ajax RC 1.0.Try to change some of your codes as the following and it should work fine.
<div>
<asp:UpdatePanel ID="upnlTimer" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblTimer" runat="server" Text="Date Time"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</div>
Wish the above can help you.

Thank you for the support

so what i add only the

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="UpdateTime"></asp:Timer>
</ContentTemplate>

</asp:UpdatePanel>
</div>

so when i place the timer control within the contenttemplate of the updatepanel so i dont need to put the timer control within the triggers of the updatepanel

so what i conclude that it will not work if i place the timer control outside the update panel.

ASP.NET AJAX Controls with SharePoint

I need to implement AJAX controls within SharePoint web parts? Is that possible? I can't seem to find any help on the Internet. Any information on what steps to follow would be greatly appreciated.

Regards,

Lilia Safronova

Check out this blog post:

ASP.NET Ajax in SharePoint


According to Daniel Larson's Blog, looks like a lot of javascripting will be required, right? What are the steps to create a very simple Ajax-enabled Hello World web part?

As soon as I inherit from SharePoint.Ajax.WebParts.AjaxWebPart, I get an error in the web part that it couldn't be found. Do you know why that is?

How do I get my hands on Ajax controls when in VS05?

I'm no very clear on what is needed to create Ajax-enabled controls for SharePoint. Would I have a web part (implemented in VS05) with a grid control for example and this .cs class would call a web service implemented with javascript (Ajax capability)?

Your help is very much appreciated.

Lilia

Saturday, March 24, 2012

asp.net 2.0 web project implement asp.net ajax control kit

Hi There,

How can i implement asp.net ajax in my asp.net 2.0 project. If i start a new project it would be easy to start this one, but i want to use in my existing project.

Thanks

There are plenty of guides on how to do this. The easiest way is to create a new temporary AJAX Enabled website, copy the missing elements out of the web.config file into your existing one and then place a ScriptManager component onto your page, before any of the components.

Hope this helps.

ASP.NET 2.0 AJAX WIndows 2003 Server - SYS UNDEFINED ERROR

I am developing one of my web sites where I am trying to implement AJAX and when I deploy it to Windows 2003 server with IIS 7, I get sys undefined JavaScript error. I searched every article on Google and did not find solution to solve it.

I am using ASP.NET 2 AJAX on IIS 7, Windows 2003 platform.

Web site where I am implementing it called47mileads.

Thank you very much for your help!!!

GK

Is the web.config modified to be ajax enabled?

Is Ajax installed on the webserver? OR Are the ajax extention dll's in the bin folder of the website?

==> You should answer YES to both questions; otherwise you get the error you mentioned above.

Kind regards,
Wim


I started project as AJAX enabled project and I tried both adding dll to bin etc...

I mean dlls not needed in bin since I am not using toolkit (but I added ajaxcontroltoolkit.dll as well). Page where it is happening:http://www.47mileads.com/Account_Login.aspx

Still same error.

Thanks,
GK


It looks like you're referencing the client side framework before it has loaded. This should be exactly what you need: http://encosia.com/2007/08/16/updated-your-webconfig-but-sys-is-still-undefined/


47mileadsdotcom:

I started project as AJAX enabled project and I tried both adding dll to bin etc...

I mean dlls not needed in bin since I am not using toolkit (but I added ajaxcontroltoolkit.dll as well). Page where it is happening:http://www.47mileads.com/Account_Login.aspx

I am not talking about the ajaxcontroltoolkit.dll here.

But I'm talking about the System.web.extentions.dll and the system.web.extentions.design.dll.

Lets say you install Ajax locally. Then those dll's get installed in the GAC (global assembly cache). This way they are accessible to all applications. Therefore they do not need to be included in the BIN of the application.

BUT: Lets say you deploy your application to a webserver. On this webserver, there is NO ajax installed, so NO dll's in the GAC of the webserver. NOW both ajax dll's need to be in the BIN of your application!

Could you please comment on my observations? Regarding the fact that I'm wrong / Or right! :)

Kind regards,
Wim


I installed ajax on the web server as well. Still not working. I also have visual studio on the server installed and I create ajax enabled web application on the server and as soon as I convert it to the web site I get sys undefined.

Thank you very much for your help.

GK


Hi GK,

im not sure but I think I heard this problem before and I think that reinstallation is the only solution (but please try to verify that through articles or threads on the internet)

try reinstalling the asp.net framework, and iis and the ajax framework.

kind regards,
wim


Are you using any URL rewriting on your site?

When I try to load your WebResources and ScriptResources, I get a 404 error. The "Requested URL" makes me wonder about rewriting issues:

Server Error in '/' Application.

The resource cannot be found.

Description:HTTP404. The resource you are looking for (or one of its dependencies)could have been removed, had its name changed, or is temporarilyunavailable. Please review the following URL and make sure that it isspelled correctly.

Requested URL:/.aspx



Yes, I use URL rewriting, but page "account login" does not use URL rewriting.

GK


Hi GK,

But as you said above, even if you create an out-of-the-box ajax enabled website, without extra functionality, even then you get the error no?

This makes me guess something is wrong with the installation ...

Wim.


47mileadsdotcom:

Yes, I use URL rewriting, but page "account login" does not use URL rewriting.

It doesn't itself, but it appears that your rewriter might be interfering with the WebResource and ScriptResource requests embedded in the page (which are used to set up the ASP.NET AJAX functionality on the client).

See if you can globally exclude *.axd requests from rewriting.


I created web application in the same directory as my web site on the server. Error I got was update pannel class reference in the code was not found. I referenced System.Web.Extensions DLL and it started working. When I was developing this project on my local box I did not have to reference System.Web.Extensions DLL since it was already referenced in my web.config. AJAX was installed on my server but web extensions assembly was not accessible from web.config. All you have to do is reference System.Web.Extensions in your references before you deploy your project.

Thank you very much for your help!!!


GK

asp.net 1.1 ajax and xml

I'm trying to implement ajax on some of my forms by having an aspx page write out xml. I'm building the xml using a string builder and useing response.contentType = "text/xml" followed by response.write at the end. If I just display the page, it renders it as xml with all the right nodes and values which is cool, but when I call xmlDoc = xmlHttp.responseXML, I'm not getting any childnodes.

The same code works if I call an xml file as the src of the ajax call.

This is my first real crack at implementing this so if anyone has any ideas, I'm open. If I'm way off, let me know.

Thanks

Dave

I wound up getting this to work by adding ContentType="text/xml" to the page directive of my xml producing aspx page.

Here's the code that rendered the xml.

Public Sub GetResponse() Response.ContentType ="text/xml"Dim strVars()As String = {"one","two","three","four","five","six","seven","eight","nine","ten"}Dim strItemVals()As String Dim sbAs New StringBuilderDim counterAs Integer = 0Dim maxAs Integer = 10Dim loXmlAs New XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8) loXml.WriteStartDocument() loXml.WriteStartElement("Response")For Each strAs String In strVarsIf counter < maxThen'Write Code via xml loXml.WriteStartElement(str)loXml.WriteString(str &" - Content") loXml.WriteEndElement() counter += 1Else Exit For End If Next loXml.WriteEndElement() loXml.WriteEndDocument() loXml.Close()End Sub