Showing posts with label application. Show all posts
Showing posts with label application. Show all posts

Wednesday, March 28, 2012

Ajax Update Panel question

Is it possible to place an update panel (or some other ajax control) on a non .aspx page? I am trying to build a poll application to use on our content pages. Unfortunately our content pages are just straight up html pages and do not run through the .net server. In fact asp.net isn't even installed on that server and likely can't be. Is it possible to have something on an html page redirect itself to the asp.net server?

I know this can't be done with regular asp.net controls but i thought perhaps the Ajax update panel would work?


If that wouldn't work is there another alternative, that still uses the .net framework?

I've seen other polling applications that let you copy and paste a simple line of javascript code onto their blogs or html pages,etc. And this piece of javascript communicates with the poll service. I was wondering if asp.net had a similar solution.

Jay

Hey,

Not on HTML pages no, only with ASPX pages. If you are using HTML, you could download the client solution they created off of the ajax.asp.net. It is the client-side libraries they used, which you can use that in HTML no problem.


Take a look at the Microsoft Ajax Library

http://ajax.asp.net/downloads/default.aspx

http://aspnetresources.com/blog/ms_ajax_cheat_sheets_batch1.aspx

ok thanks. I looked at these and its a start, although it looks pretty overwhelming for a newbie. I don't know where to begin.

I believe this is the online documentation for the client libraries correct?

http://ajax.asp.net/docs/ClientReference/default.aspx

Off-hand would you happen to know of any websites or tutorials or that would explain how to use the client libraries a little better?

Jay


This blog entry has an example and some links

http://blogs.msdn.com/brada/archive/2006/10/23/microsoft-ajax-library-at-the-ajax-experience.aspx

In fact asp.net isn't even installed on that server and likely can't be.

AJAX.net is based on theXMLHttpRequest, which works only for the same domain, AKA sandbox. Depending on your network anupdatepanel based on MicrosoftAjax.js may be very complex to implement. It is easier to haveHTML and.net on one server only.

Is it possible to have something on an html page redirect itself to the asp.net server?

Solution A: you can (re-)direct the user to your poll server in using a simplelink or the Javascriptlocation object.


B and C are likely the paths i will take i think. I've played around with the IFRAME and it seems to work well. I was trying to avoid it but i guess its not so bad. Thanks.

J

Monday, March 26, 2012

AJAX Toolkit CalendarExtender Issue

I am going to write a web application using AJAX Toolkit. In one of the application modules, I have to use calendar control. To meet this requirement I am using CalendarExtender with a TextBox control. I have a problem when I submit the form having this controls combination. The problem is that I am unable to get Text field value after submitting the form. I have written a sample page to make my point cleat to you. Here is the code:


<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
string strDate = "";
strDate = txtCheckinDate.Text;
}

</script>

...

...

<div>

<asp:TextBox ID="txtCheckinDate" runat="server" ReadOnly="True"></asp:TextBox>
<asp:ImageButton ID="btnCalendar" runat="server" AlternateText="Click to show calendar" ImageUrl="~/images/Calendar_scheduleHS.png" />
<div style="font-size: 90%"><em>(Click the image button to open the calendar)</em></div> <br />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="MMMM d, yyyy" PopupButtonID="btnCalendar" Animated="true"
TargetControlID="txtCheckinDate"> </ajaxToolkit:CalendarExtender> <br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /><br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>


Would you please help me to find out the cause of problem?

Waiting your kind reply.


I created my own...Works for me. I did notice a few thing.

The ScriptManager must appear before any control that needs it.

Your page should include something like this...

<%@. Register Assembly="AjaxControlToolkit, Version=1.0.10301.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

and your tag prefix should look something like this

 <cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="MMMM d, yyyy" PopupButtonID="btnCalendar" Animated="true" TargetControlID="txtCheckinDate"> </cc1:CalendarExtender>

I hope that helps.

AJAX to grab a server controls RenderContents() output

Hi everyone,

My web application dynamically loads custom built server controls at runtime from seperate assemblies using the reflection namespace. Everything works fine, and the server controls display on the page as required.

I would like to extend this, to enable the server controls to be displayed asycronously. Is it possible to make an asynronous request to the web server and then when the server control is loaded, pass back the HTML that is generated in the RenderContents() method as the responseText?

How would I go about doing this? Example code would be great.

Any help is much appreciated,
Ad

Hi,

I'm still stuck on this on this one, any ideas?

Thanks again,
Ad


Hi,

Please refer to this:Emailing the Rendered Output of an ASP.NET Web Control, it implements the function you need.

Hope this helps.

NOTE:This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


This link looks like a good start, but a bit more sample code especially on the Ajax part would be very helpful.

Regards

Dion


Hi Dion,What probelms do you have after you've got the output of a control?

Saturday, March 24, 2012

AJAX throw a "Sys.WebForms.PageRequestManagerErrorException" with Server.Transfer

Hi,

First, I′m from Brazil and I don′t know to write English very well, but try show my problem.

I have an application ASP NET AJAX 1.0 with 2 pages in diferent folders, how show the schemma:

Folder 1HomeFolder 2PageWithUpdatePanel

PageWithUpdatePanel contains a UpdatePanel with a Button Control named Button1.

When Home calls PageWithUpdatePanel with Server.Transfer, an error happens in browser when Button1 is pressed in a second time. Any Control causes the exception.

Details from exception message:

Sys.WebForms.PageRequestManagerErrorException: unknown error ocurred while processing the request on the server. The status code returned from the server was: 404

Another message happens with DropDownList:

Sys.WebForms.PageRequestManagerErrorException: The message received from the server cound not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '<html xmlns="htt'.

I read that "ScriptManager1.RegisterPostBackControl(Button1)" resolves the problem. But is the same that don′t uses Ajax. That result isn′t satisfactory.

With ATLAS the error don′t happens.

The Microsoft Support has resolved the question. Past the Code after UpdatePanel: function EndRequestHandler() { theForm.action = "../NewFolder1/Default.aspx"; theForm._initialAction = theForm.action; } if( typeof(Sys) != "undefined" ) { EndRequestHandler(); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); }

I have the same issue but I wasn't able to translate the solution from the answer above. Can somebody translate the above answer into VB?

Thank you.


The code is to place in HTML Markup, not in Code-behind. Is JavaScript. The code, with line-breaks is:

function EndRequestHandler()
{
theForm.action = "../NewFolder1/Default.aspx";
theForm._initialAction = theForm.action;
}
if( typeof(Sys) != "undefined" )
{
EndRequestHandler();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}


Hellooo, I Have the same problem with you, can you help me how to resolve them.

where i can put that code ? can you give me the full source code ?

Thanx And Sorry My English so badBig Smile


No problem, I don′t speak English so mutch too. About the code, you have to place it in HTML markup, after the end tag of UpdatePanel.


I was trying to execute the Server.Transfer([myASPXpage]) inside the click event for my Save button. There were a couple posts on the WEB that poo pooed the idea of using Server.Transfer() in general but for my scenario it ( I thought) was necessary. After the user saved their information I wanted to return them to the main page. On the main page I was using the Request object to verify if the user was coming from a valid URI (make sure the user was signed in). Using Response.Redirect was not helpful because there wasn't a PreviousPage object to check (as there would have been if Server.Transfer was available).

In the end the solution was simple, I had overthunk the scenario by a mile. On my main page I utilized the User object checking the identity to verify that the user was signed in and valid.

Hope that makes sense...

Wednesday, March 21, 2012

Ajax support by Web Hosts?

I currently use 1and1.co.uk as my web host on a shared server. i have an asp.net application under development and all is looking good. I would extend the look and feel for my application by using AJAX.

does my web host need to support AJAX or is it part of my application and when compiled will run on my host?

Thanks in advance

Matt A

As of Beta 1 and 2, the AJAX dll is part of the GAC, so a server admin needs to install it on the server, won't work like before where you had the dll in your bin dir.

Basically, you'll have to wait till your host adds AJAX support, which probably won't be till the final version is released...


Hi,

ASP.NET AJAX Beta2 is not a part of .Net Framework2.0,.

We are installing externally, in installation it will add "Microsoft.Web.Extensions.dll","Microsoft.Web.Extensions.Design.dll" to GAC.

Suppose if your webhost is not having AJAX Beta2, how can you run AJAX functionality at host.

If you want to use AJAX functionality there are two ways,

1) At the time of deployment you should add the two DLL to GAC,

2) Webhost must be installed AJAX Beta2

Pradeep Kumar Bura


Has anybody tried just copying the dlls to the bin directory of the website when using a third party web host? Any other workarounds out there?

JDG.


ajax stopping all events

Hi,

I'm trying to implement some ajaxfeatures in current asp application. (App has been converted to vs2005 recently).

I've already used ajax update panels with popupcontrolextenders and scriptmanager on one of the sites. But when Im trying to use similar pattern in another site

(update panel + gridview) everything stops working. By everything I mean that when I add scriptmanager control to the page, most events stop to fire at all. Only gridviews paging and sorting events work. Here some code:

<%@dotnet.itags.org. Page Language="c#" MasterPageFile="~/MasterPage.Master" Codebehind="PC_Scor_Search_Results.aspx.cs"
AutoEventWireup="True" Inherits="WBOnline.PC_Scor_Search_Results" %
<%@dotnet.itags.org. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="Microsoft.Web.UI" TagPrefix="ajaxExt" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> <asp:Content ID="content12" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"
<ajaxExt:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</ajaxExt:ScriptManager>

<asp:ObjectDataSource ID="objComboWind" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetWBNamesWithIDEmpl" TypeName="WBOnline.BLL.Dictionaries_BLL"></asp:ObjectDataSource
<table border="0"> <tr>
<td style="height: 64px">
<table cellspacing="0" cellpadding="0" width="907">
<tr>
<td class="tableDanekomorka">
</td>
<td class="tableDanekomorka" colspan="2" rowspan="1">
</td>
</tr>
<tr>
<td class="tableDanekomorka" style="height: 19px">
<asp:Label ID="lblIloscWynikow" runat="server" CssClass="pole" Height="4px" Font-Size="XX-Small" Font-Names="Verdana">Ilo?? wyników na stronie</asp:Label><asp:DropDownList ID="ddlIloscWynikowNaStronie" runat="server" Width="80px" Font-Size="XX-Small" Font-Names="Verdana">
<asp:ListItem Value="20">20</asp:ListItem>
<asp:ListItem Value="50">50</asp:ListItem>
<asp:ListItem Value="100">100</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnOdswiez" runat="server" CssClass="przycisk" Font-Names="Verdana" Font-Size="XX-Small" OnClick="btnOdswiez_Click" Text="Od?wie?" />
<asp:Button ID="btExcel" runat="server" CssClass="przycisk" OnClick="btExcel_Click" Text="Eksport" Font-Names="Verdana" Font-Size="XX-Small" /></td>
<td class="tableDanekomorka" style="height: 19px">
<asp:Label ID="lblWindykator" runat="server" CssClass="pole" Height="4px" Font-Size="XX-Small" Font-Names="Verdana" Width="80px">Windykator:</asp:Label><asp:DropDownList ID="ddlWindykator" runat="server" Width="200px" Font-Size="XX-Small" Font-Names="Verdana" Enabled="False" DataSourceID="objComboWind" DataTextField="Nazwisko" DataValueField="IDPracownik">
</asp:DropDownList>
<asp:Button ID="btnPrzydzielWindykatora" runat="server" CssClass="przycisk" OnClick="btnPrzydzielWindykatora_Click" Text="Przydziel wszystkie" Font-Names="Verdana" Font-Size="XX-Small" /></td>
</tr>
</table
</td>
</tr>
<tr>
<td>
<div> <asp:GridView ID="gvSearchResults" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="objSearchResults" OnSelectedIndexChanged="gvSearchResults_SelectedIndexChanged" PageSize="20" Font-Size="Small">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID">
<HeaderStyle CssClass="hiddencol" />
<ItemStyle CssClass="hiddencol" />
</asp:BoundField>
<asp:BoundField DataField="Regres" HeaderText="Regres" ReadOnly="True" SortExpression="Regres">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="OrderNumber" HeaderText="Nr wew" ReadOnly="True" SortExpression="OrderNumber" />
<asp:BoundField DataField="Name" HeaderText="Windykowany" ReadOnly="True" SortExpression="Name">
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="WindykatorID" HeaderText="WindykatorID" ReadOnly="True" SortExpression="WindykatorID">
<HeaderStyle CssClass="hiddencol" />
<ItemStyle CssClass="hiddencol" />
</asp:BoundField>
<asp:BoundField DataField="Windykator" HeaderText="Windykator" ReadOnly="True" SortExpression="Windykator">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="DataPrzekazania" HtmlEncode="False" DataFormatString="{0:d}" HeaderText="Data przekazania" ReadOnly="True" SortExpression="DataPrzekazania">
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="DataWizyty" HeaderText="Data wizyty" ReadOnly="True" SortExpression="DataWizyty">
<ItemStyle Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:CheckBoxField DataField="Zamknieta" HeaderText="Zamkni?ta" SortExpression="Zamknieta" />
<asp:CommandField SelectText="Pobierz" ShowSelectButton="True" /
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="objSearchResults" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetScoringSearchResults" TypeName="WBOnline.BLL.PC_Scor_BLL" OnSelecting="objSearchResults_Selecting" EnableViewState="False">
<SelectParameters>
<asp:Parameter Name="idEmployee" Type="Int32" />
<asp:Parameter Name="orderBy" Type="String" />
<asp:Parameter Name="sortOrder" Type="String" />
</SelectParameters>
</asp:ObjectDataSource> </div>
</td>
</tr>
</table>
</asp:Content>



Solution: Install IE 7.0 (or some updates for IE6.0), install ajax rc december.

I don't see you using any UpdatePanel ... !?

WS


Damn, I posted wrong version. I did use updatepanel (it contains gridview with objectdatasource).

Problem with stopping all events disappeared, now I can't get rid of an 'sys is undefined' error.

http://forums.asp.net/thread/1503374.aspx

Ajax Slideshow from Database

I have a web application with a database that stores, among other things, productname, description, and imagefilename.

i have been beating my head against the wall trying to write javascript or a web service to populate an Ajax slideshow using that data.

Can anyone steer me out of this dead end?

Thanks in advance for any help.

I am currently working on a similiar project. I am not sure if I am doing things 100% correctly, but I basically followed the examples in the Toolkit. I populate the AjaxControlToolkit.Slide objects individually from the filename and then create an array AjaxControlToolkit.Slide[] full of these objects and return it via the GetSlides() web service. Hopefully you will know how to get the data out of your particular database and populate the slide objects.

I personally wrote wrappers SlideShowDocuments for my slide internal data mostly because I needed to keep track of which slide was on the screen at a time, and I didn't want to use a hack with the description fields. Inside the SlideShowDocuments object is where I connect to the Database and create the prepared information for the Slide objects.

I basically used the contextKey to create the SQL to select the appropriate rows. Then I move the information and formatted the filename into my internal structure for a SlideShowDocument object.

You shouldn't HAVE to write any Javascript, the SlideShowExtender does all the work for you! Here is how I went about it... hope this helps!

[System.Web.Services.WebMethod]

[System.Web.Script.Services.ScriptMethod]publicstatic AjaxControlToolkit.Slide[] GetSlides(string contextKey)

{

SlideShowDocuments _slideShowDocuments =newSlideShowDocuments(contextKey);

_slideArray =new AjaxControlToolkit.Slide[_slideShowDocuments.Count];

for (int i = 0; i < _slideShowDocuments.Count; i++)

{

_slideArray[i] =new AjaxControlToolkit.Slide(_slideShowDocuments[i].Filename,"","");

}

return _slideArray;

}


Thank you for your advice. I actually stumbled across another post on the forum that really did the trick for me and may be helpful to you too.

http://forums.asp.net/p/1115257/1728447.aspx#1728447

Thanks for taking time to reply.

Steve