Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts

Wednesday, March 28, 2012

PostBack is happening even after using Update Panel and Script Manager

Hi,

I have a ASP.NET web application. I have a gridview and using a RowDataBound andRaisePostBackEventevent for getting the GridView details in the controls below like textboxes, dropdown etc. Now i am using Ajax Extensions controls like Update Panel and Script manager to avoid a postback happening when the GridView row is clicked. Even after implementing them postback is happening. Please see the code bits and let me know if i am missing somewhere.

UI

<asp

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

<

asp:UpdatePanelid="UpdatePanel1"runat="server"UpdateMode="Conditional">

<contenttemplate>

<asp:GridViewID="GridView1"runat="server"OnRowDataBound="GridView1_RowDataBound"CssClass="sampletable"AlternatingRowStyle-CssClass="d1"ShowHeader="true"ShowFooter="false"AllowPaging="true"AllowSorting="true"AutoGenerateColumns="false"DataKeyNames="ProjectID"Width="100%"PageSize="5"><Columns>

<asp:BoundFieldVisible="false"HeaderText="Project ID"DataField="ProjectID"SortExpression="ProjectID"/><asp:BoundFieldHeaderText="Project Name"DataField="ProjectName"SortExpression="ProjectName"/><asp:BoundFieldHeaderText="Site Name"DataField="SiteName"SortExpression="SiteName"/></Columns></asp:GridView><asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:ButtonID="Button1"runat="server"Text="Button"/>

</

contenttemplate>

<

Triggers>

<

asp:AsyncPostBackTriggerControlID="GridView1"EventName="RowDataBound"/>

</

Triggers>

</

asp:UpdatePanel>

And theCode behind for RowDatabound event is

protected

void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

try

{

if (!((e.Row.RowType ==DataControlRowType.Pager) || (e.Row.RowType ==DataControlRowType.Header) || (e.Row.RowType ==DataControlRowType.Footer)))

{

System.Web.UI.

ClientScriptManager cs = Page.ClientScript;//Assign Row Index. This row index used in finding the ID of the clicked rowint intRowIndex = e.Row.RowIndex;

e.Row.Attributes.Add(

"onClick", cs.GetPostBackEventReference(this, intRowIndex.ToString().Trim()));

e.Row.Attributes.Add(

"onKeyDown","if( event.keyCode == 13 ) " + cs.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString().Trim()));

}

}

catch (System.Exception ex)

{

//OnError(ex);

}

}

The code looks good, did you try a easy test to see if the postback is hidden?

http://alpascual.com/blog/al/archive/2006/12/21/Code-Snip-_2200_AJAX-Timer_2200_.aspx

Try the sample below and let me know if you see the postback


Thanks for the Quick Response.

But i could not get exactly what you want to convey.

regards,

Parimal


Ok, wrap a asp:button around an updatepanel and let me know if you see the postback

Hi,

The button is working fine without any post back. The Post back is happening when Grid Row is clicked as it call the RaisePostBack event to get the Row details. That event is coded as we have not used any command template in Grid.

regards,

Parimal


OnRowDatabound would not make sense for an async trigger. The user clicking the row and getting a postback via the javascript you added to the onclick is not the same. If you take out the trigger and just add ChildrenAsTriggers="true" to the UpdatePanel it would probably work as you expect.

One other thing - in this code:

"onClick", cs.GetPostBackEventReference(this, intRowIndex.ToString().Trim()));

e.Row.Attributes.Add(

"onKeyDown","if( event.keyCode == 13 ) " + cs.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString().Trim()));

Change "this" to GridView1. You want to create a postback for your gridview, not the whole page. Since you're creating a custom postback you'll also need to register for event validation, or disable event validation in your page.


Thanks for the response. But still post back is happening. I will explain in details

1. I have a Gridview RowDataBound event which fires when Data is bounded to Grid.

2. I have aRaisePostBackEvent which fires when the row in the Grid is selected and this causes the Post Back event.

3. Aslo my UserControl is implementingIPostBackEventHandler interface.

Thanks in Advance,

Parimal

Postback Multitask progress bar (ajax)

hello

I have a asp.net page that takes several actions uppon a button click.

Suppose this page triggers 3 functions on that button click: (THIS IS JUST AN EXAMPLE)
1) Saves data to local data base
2) Export data do internet data base
3) send emails to 50 users reporting this update

What I want to do is show the user wich action the server is performing at the moment.
basically, it should show (on a Modal PopUP, i figure) all the 3 steps taken.
1) ...saving data...
2) ...exporting data ...
3) ... notifying users ...

does anyone have a solution for this?

thanks

Checkout this threadhttp://forums.asp.net/t/1133013.aspx

postback problem

i have asp.net web page,on page load i create a simple html table with fixed no of rows and no of columns and their names are determined dynamically.now i have few javascipt functions for adding a row to table,for adding another column to table and for removinga row from table.

also i have a asp:button on click of which a xml file is generated from the data filled in by user in the table.but as soon as i hit the asp button to generate xml all newley added rows and columns are deleated.Is it possible to call a server side function without posting the page back.

Yes, it is

take a look at this article about client scripts callbacks:

http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/

Cheers,

Yani


hey went throught the article actually i mean new to all this so didnt get it completely some code help from ur side will be appriciated

actually i have a method on server side that accepts the html table parses it and writes the data of html table in a xml file.

and i want to call this method on click of a button and without postback.

thanx in advance

sandeep


Sorry man,

I haven't put the client scripts callbacks into practice yet too.

I was going to use them to create a dynamic progress bar, but then i've decided to use the ajax update panel.

It was much faster and cheaper.

Cheers,

Yani

Postbacktrigger problem

I am creating a vb.net/asp.net 2005 app using a tabcontrol and I am trying to use a button inside the updatepanel and inside the tab and I am using the following syntax:

<CODE>

<asp:UpdatePanelID="pnlTest"runat="server"RenderMode="Inline"UpdateMode="Conditional">

<Triggers>

<asp:AsyncPostBackTriggerControlID="TabContainer1"EventName="ActiveTabChanged"/>

<asp:PostBackTriggerControlID="btnPreview"/>

</Triggers>

<ContentTemplate>

....everything else here...tab control...

</ContentTemplate>

</CODE>

But I keep getting an error as follows:

<ERROR>

A control with ID 'btnPreview' could not be found for the trigger in UpdatePanel 'pnlTest'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.InvalidOperationException: A control with ID 'btnPreview' could not be found for the trigger in UpdatePanel 'pnlTest'.

</ERROR>

I am very confused because I know the control is there and when I go to the vb code-behind I am able to see the code in the dropdownlist that contains all controls for the aspx page. Does anyone have an idea what I'm doing wrong? thanks

Since your button is in the UpdatePanel you do not need to create trigger for it.


Hi Myroncope,

Here is my sample code which was written in c#. It has been tested and works fine. If you install a tool named "Web Development helper", maybe an error dialog will be sent to you, don't mention it.Press continue!

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="UpdatePanelTest2.aspx.cs" Inherits="UpdatePanelTest2" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="TabContainer1" EventName="ActiveTabChanged" /> <asp:PostBackTrigger ControlID="btnPreview" /> </Triggers> <ContentTemplate><%=DateTime.Now.ToString()%> <cc1:TabContainer ID="TabContainer1" runat="server" OnActiveTabChanged="TabContainer1_ActiveTabChanged" AutoPostBack="True" > <cc1:TabPanel ID="TabPanel1" runat="server" > <HeaderTemplate> 1111</HeaderTemplate> <ContentTemplate><%=DateTime.Now.ToString()%></ContentTemplate> </cc1:TabPanel> <cc1:TabPanel ID="TabPanel2" runat="server"> <HeaderTemplate> 2222</HeaderTemplate> <ContentTemplate><%=DateTime.Now.ToString("yyyy-MM-dd")%></ContentTemplate> </cc1:TabPanel> </cc1:TabContainer>  <asp:Button ID="btnPreview" runat="server" Text="btnPreview" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
 By the way, my AJAX Control Toolkit version is 10618. If an error occured while you execute the code above. Suggest you check your AJAX Control Toolkit version.
If the error information still exist, please let me know.

MyronCope:

I am very confused because I know the control is there and when I go to the vb code-behind I am able to see the code in the dropdownlist that contains all controls for the aspx page. Does anyone have an idea what I'm doing wrong? thanks

Are btnPreview visible?

You could also try to use the ClientID or UniqueID value of btnPreview for postbacktrigger's ControlID attribute. Maybe one of them works.

And finally you could also tryRegisterPostBackControl(Control) method of scriptmanager in code-behind.


Hi, MyronCope

You can add an invisible button out of the updatePanel,set the invisible button as aPostBackTrigger of theUpdatePanel.

Then on the client-side click event of the 'btnPreview', trigger the click event of that invisible button.

<div style="visibility:hidden"><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" UseSubmitBehavior="false" /></div>

<input type="button" onclick="javascript:document.getElementById('Button1').click();" name="Button1" value="Button" id="
'btnPreview'" /></div>

The same solution solved all of this kind issue!

Check the following links:

http://forums.asp.net/t/1116956.aspx

http://forums.asp.net/t/1117770.aspx

http://forums.asp.net/t/1115934.aspx

http://forums.asp.net/t/1116851.aspx

Hope this helps.

Let me know if you need more info.

Povide Drag Option across Datagrids(Drag and Drop)

Thanks in advance for assisting me,

I am developing a asp.net web application(VB.Net).

I am New to AJAX and have a requirement where i should be able to select(say using a check box) and drag(move) a particular or a set of rows from one datagrid to a another datagrid in the same page.

Is this feasible ,what should be the approach......

Hi,

If your using checkbox or any other way to mark the rows you wanted move..... you can either create a xml ....(The data to be moved) or you can create a temp table and you can update the new datagrid... well, I am not quite sure that, through client side code the data can be moved between two datagrid is possible..? May be primary datagrid data can be as XML document though which the secondary data grid can be updated......

Pre Fetching Data - InitialData Control?

Are there any features in ASP.NET AJAX for pre-fetching data? I'm thinking of a feature that would prevent the app from frequently pinging the web server for data (i.e. auto complete, cascading drop down).

From what I can tell, at one point there was an "InitialData" control that was aimed at sending a chunk of data down with the first request. It seems however that this control has been pulled from both Beta2 and the Futures. Does anyone know the status of this control?

Thanks!

Here is a solution for pre-fetching data for your reference.
????At any point in an Ajaxian application's lifetime, the user has the option to perform a number of activities. At the very least, there are always two things the user could do in the next moment: (a) close the application (by quitting the browser or closing the application window/tab); (b) nothing. And of course, there are usually a multitude of application-specific activities that can occur at any time.

Some of these user activities will trigger a remote scripting call to the server before returning for browser-side processing, and the delay will usually be noticeable. That's unfortunate for usability, because responses should ideally feel as if they are instantaneous. The computer not being able to freeze time, the response will never really be instantaneous. But from a usability perspective, it should ideally give that impression. To provide results at a pace that is below the level of human consciousness, a typical guideline is that the application should respond in under 10 milliseconds. That's a hard ask when a trip to the server is required. Especially in a global context, where a trip to the sever and back might cost a second or more due to network overheads.

The obvious motivation for instantaneous feedback is throughput: the user can achieve more because they're not waiting as long for results. Actually, that's not such a major issue: what's a few seconds when you're working on a document for half-an-hour?

Often, the biggest downside of latency is the distraction it causes. The user is focused on a task, and may well be in a state of "flow". A delay will cause a loss of concentration and, in addition to the time it takes to get back to this train of mind, there's also a risk that an idea might be lost forever.

Another problem is simply user frustration. Users generally like to feel in control of a system, so it's not ideal when the system causes delays, especially unpredictable delays.

A final issue with latency is its effect on responsivenes. When users are making decisions in real-time, they need real-time data. For an application such as financial trading, even a consistent 100-millisecond lead can make a big impact on overall performance.

Pre-fetching attempts to remove the delay altogether for certain user actions. It's usually infeasible to pre-fetch results for all actions, so the designer must be judicious in anticipating actions. We are especially interested in actions which are likely to be performed, so that the probability of no response is high. Furthermore, even unlikely actions may also be worth pre-fetching for, if they are critical to the application. Imagine an emergency response system, where the choices are "View your preferences", "Work on reports", and "Dispatch emergency units". The last of these might not occur very often, but which one would you like to be prefetched?

Another downside of pre-fetching is erratic behaviour. A good usability principle is consistent behaviour, but with Predictive Fetch, the user may be surpised that some commands respond instantaneously, while virtually identical commands take a long time. To make the waiting time more comfortable, consider showing a Progress Inidicator.
Advanced Networking Scenarios Not Available in the RTM Release
The following networking features of the CTP release willnot be available in the RTM release:
?The iframe executor. This feature provided support for cross-domain calls, and is not available in RTM release in part because of security concerns.
?The following infrequently used features:
oAssembly-based method calls.
oInitialData control.
oBatching of Web service calls.

Preferred Approach to Existing .Net Server Controls and Client Scripting

In asp.net 1.1, the mechanism I used on many occassions is to add attributes to work some client side script. ie. a .NET dropdownlist:

ddlMonOfficeStart.Attributes.Add("onChange",string.Format("return ValidateTimeSelection('{0}', '{1}', 'divMonOfficeStart', 'divMonOfficeEnd')", ddlMonOfficeStart.ClientID, ddlMonOfficeEnd.ClientID));

First off, I'm not sure if the above approach is necessary with Atlas, but the next question is how to handle this in javascript:

Do I simply get the clientid of the dropdownlist and do my 'normal' javascript - or at this point do I try to 'cast' this dropdownlist object on the client side to the Sys.UI.Select object?

I see this example here:http://atlas.asp.net/docs/util/srcview.aspx?path=~/atlas/samples/controls/simple_control.src - but in this example, these are 'html' elements, not .net server side controls?

In the above attribute, the script might look like this:

<scripttype="text/javascript">

function ValidateTimeSelection(g_ddl1, g_ddl2, g_div1, g_div2) {
var dd1 = ($(g_ddl1));
...
}

</script>

in this line here: var ddl = ($(g_ddl1)) I'd rather like to do something like:

var dd1= new Sys.UI.Select($(g_ddl1));

and utilize the Atlas script library.

Hopefully this makes sense :)

You can simply continue to build your custom control with regaulr JavaScript that is rendered by the control through the Page.ClientScript.RegisterXXXScript methods. Where your 'behavior' is simple, this might still be the best approach.

However, if you wish to build a new control that makes use of the Atlas libraries and perform much more rich behavior in the client, then you can begin to develop custom controls that implement IScriptControl, that can then render the required xml-script (declarative Atlas script) to the client. You'll need of course to ensure that there is a Scriptmanager in the page, in order to render your script. This means that you can divorce yourself from writing complex JavaScript etc.

If you have bew custom behaviors that you want your custom control to make use of, then you could potentially build Atlas client-side behaviors/controls that agfain you can render through the custom control. This would also yield those client-side components for other client-side rich applications.

Monday, March 26, 2012

Prerequisites at ASP.NET Hoster for Atlas

My sites are hosted by a normal ASP.NET (2.0) hoster. Do I need any prerequisites on the hosted machine to enable Atlas on my website?

Thanks

Ralf

As of the March release Atlas should work fine as a medium trust application. Therefore you should be able to simply xcopy your Atlas app to the server.

One problem you may face however is that your host does not map the new ".asbx" extension (which is used for webservice bridge files). This means you can probably not use this feature until your host would add this mapping.

Here is additional material on .asbx files and how to route bridge calls through an .axd extension without having to register the .asbx extension with IIS, great for a hosted account.

http://atlas.asp.net/docs/Walkthroughs/DevScenarios/bridge.aspx
http://atlas.asp.net/docs/atlas/doc/bridge/tunnel.aspx

thanks
-jhawk


Thanks for the answer. I will try it out.

print button of Crystal report 11.5 didnt show pop-up dialog with AJAX

I have developed one web application with ASP.Net 2.0 with AJAX 1.0 and Crystal Report 11.5 Release 2.

When i put Crystal Report viewer in AJAX's update panel, Crystal report viewer is opened properly, but when i try to export or print the report from Crystal Report viewer, it is not showing any dialog box for export or print. Print mode of Crystal report viewer is ActiveX.

Can any body help regarding this problem with example(if possible) ?

Regards,

Krunal Shah

http://forums.asp.net/thread/1325110.aspx
(UpdatePanel does not allow the CrystalReportViewer control to print or export.)

http://forums.asp.net/thread/1660467.aspx
(button inside update panel Firefox problem)

etc., etc.

Printable Client Reference Available?

Is there a pdf or word doc of the complete ASP.NET AJAX client reference that is ready to print on standard 8 1/2" x 11" paper?

hi,

AFAIK the closest you can get is the downloadable documentation in ajax.asp.net/docs

Saturday, March 24, 2012

Problem binding DataTable to ListView using "set_data(result)"

Hello,

I'm calling a web service which is providing a DataTable to my client ASP.NET AJAX javascript code. I'm then trying to bind that data table to a client listview control. The code runs without error message but no results are displayed, despite the datatable having positive content. The problem seems to arise because the "set_data" makes a call to "render" and in that method it checks the validity of "get_length", which the client DataTable does NOT support, so the code falls out to the "Empty Data" template. Basically it seems that ASP.NET AJAX is not expecting to see a DataTable at all, but something else. Can anyone help me with this please?

Here is my page code, the WebService.asmx simply returns a DataTable and "main()" simply wires up the button to kick the process off. the commented code will successfully display the data as an unordered list (simulating a listview):

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="ListViewUnorderedList.aspx.cs" Inherits="ListViewUnorderedList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script>
function main()
{
document.getElementById("btnLoadVendors").onclick = getVendors;
}

function getVendors()
{
var onVendors = function(result)
{

// result is a dataset or data object
var ele = document.getElementById("output");
var ctl = ele.control;
ctl.set_data(result);

/* This would work and do the same job...
ele.innerHTML = "<ul>";
for (var i=0; i<result.rows.length; i++)
{
ele.innerHTML += "<li>" + result.rows[i].Name + "</li>";

}
ele.innerHTML += "</ul>";
*/
}
WebService.getVendors(onVendors);
}

</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" />
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewGlitz.js" />
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewDragDrop.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
<script>
Sys.Application.get_events().addHandler("load", main);
</script>
<input id="btnLoadVendors" type="button" value="Load Vendors" />
<!-- Template for output -->
<div id="output">
Vendor list goes here.
<div style="display:none">
<div id="vendorsLayout">
<ul id="vendorsItemParent">
<li id="vendorsItem">
<span id="vendorsName">Vendor Name goes here</span>
</li>
</ul>
</div>
</div>
</div>
</form>



<script type="text/xml-script">
<page xmlns="http://schemas.microsoft.com/xml-script/2005">
<components>
<listView itemTemplateParentElementId="vendorsItemParent" id="output">

<layoutTemplate>
<template layoutElement="vendorsLayout" />
</layoutTemplate>

<itemTemplate>
<template layoutElement="vendorsItem">
<label id="vendorsName">
<bindings>
<binding dataPath="Name" property="text" transform="ToString" />
</bindings>
</label>
</template>
</itemTemplate>

</listView>
</components>
</page>
</script>
</body>
</html>

bump

With hindsight, perhaps I've worded this problem all wrong.

Basically, the "set_data" method of a client control does not accept/understand an ASP.NET AJAX Client datatable object, as I was led to believe it did.

So what object structure do you pass to it?


Well, it looks as if the answer is to pass it the "rows" property of a datatable, this seems to work:

document.getElementById(

"output").control.set_data(result.rows);

Problem calling webservice from client code

Hi All,

I am trying to call a webservice method on a ASP.NET page (in AJAX enabled website). I have my asmx file in the same project as my ASP.NET page. When i try to compile the project , i am getting a "Could not create type TestService" error. Can some body tell me what exactly is the problem here?

Thanks

Mahesh

Confused cud u have given namespace reference of web.script.services.scriptservices

as using web.script.services.scriptservices

& inherite [ScriptServices]


Thanks for the reply ranjeet. But i don't really get the gist of your message , can you please be more clear? I am copying my webservice code below for your reference:

using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Web.Script.Services;

using System.Data.SqlClient;

using System.Data;

///<summary>

/// Summary description for TestService

///</summary>

///

namespace MyTestService

{

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

publicclassTestService : System.Web.Services.WebService

{

[WebMethod]

[ScriptMethod]

publicDataSet GetEmployeeDetails(int empID)

{

String strConnectionString =String.Empty;

String strQuery ="Select * from Employee where EmployeeID = " + empID; ;

strConnectionString ="Server=PC21172\\SQLEXPRESS;Database=EmployeeDB;user=sa;pwd=pwd";

//Get the employee details for the passed id

SqlConnection c =newSqlConnection(strConnectionString);

c.Open();

SqlDataAdapter dataAdapter =newSqlDataAdapter(strQuery, strConnectionString);DataSet dsEmployeeDetails =newDataSet();

dataAdapter.Fill(dsEmployeeDetails);

return dsEmployeeDetails;

}

}

}

Thanks

Mahesh


The DataSet and DataTable is supported in the v1.0. You have add the preview version.


Hi,

I have infact downloaded the January CTP and i am able to return the datatable. Now th issue is , how can i bind the datatable or dataset that i return from the webservice to a ASP.NET datagrid control in javascript call back function. Can somebody help me on this?

Thanks

Mahesh


The Asp.net DataGrid/GridView does not have any objectmodel in the client side. Few days back I wrote a component which does the exact thing, Checkout the following article:http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

Problem calling Web Service using the DynamicPopulate Extender - Web Service Call Fails: 5

Hi, I'm quite new to ASP.Net AJAX so please forgive my ignorance.

I have downloaded and installed the RC1 version and am following through some of the tutorial videos.

I am having a problem with the Dynamic Populate Extender example. I have created some asp controls with onclick events calling a javascript function. From there I am attempting to use a dynamic populate extender control to call a web service - it's a function declared on that ASPX page as the tutorial explains in necessary and decorated with the System.Web.Services.WebMEthod AND System.Web.Script.Services.ScriptMethod attributes.

Everything works as expected until I attempt to pass a parameter to the web services - in fact until I declare the web service function with a parameter. Once I do this, all that is returned to (or at least all that displays in) the control linked to the DynamicPopulateExtender is "Web Service Call Failed: 500".

Can anyone possibly put me on the right track here? (or would I need to post some code examples?)

Thanks in Advance.

Stu.

the tutorial is in beta version.

i will post my code for you

ASPX page

<%@. Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="DynamicPopulateDemo._Default" %>

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>

</head>
<body>

<form id="form1" runat="server">
<script type="text/javascript">

function updateDateKey(value) {

var behavior = $find('dpe');

if (behavior) {
behavior.populate(value);
}

}

Sys.Application.add_load(function(){updateDateKey('G');});
</script>

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:DynamicPopulateExtender ID="dpe" runat="server" ClearContentsDuringUpdate="true"
PopulateTriggerControlID="Label1" TargetControlID="pan" ServiceMethod="GetHtml">
</cc1:DynamicPopulateExtender>

<p>
<asp:Label ID="Label1" runat="server" Text="Label" CssClass="subheading">Time at the server:</asp:Label>
</p>
Choose a date/time format:<p>
<label for="r0"><input type="radio" name="rbFormat" id="Radio1" value='G' onclick="updateDateKey(this.value);" checked="checked" />Normal</label><br />
<label for="r1"><input type="radio" name="rbFormat" id="Radio2" value='d' onclick="updateDateKey(this.value);" />Short Date</label><br />
<label for="r2"><input type="radio" name="rbFormat" id="Radio3" value='D' onclick="updateDateKey(this.value);" />Long Date</label><br />
<label for="r3"><input type="radio" name="rbFormat" id="Radio4" value='U' onclick="updateDateKey(this.value);" />UTC Date/Time</label><br />
</p>
<br />
<p>

This time is dynamically formatted and<br /> returned as HTML from the server:

<asp:Panel ID="pan" runat="server" BorderColor="#404040" BorderStyle="Solid" BorderWidth="1px" Height="15px" HorizontalAlign="Center" Width="380px">
</asp:Panel>
</p>

</form>


</body>

</html>

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;

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

}
[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod()]
public static string GetHtml(string contextKey)
{
System.Threading.Thread.Sleep(250);
string value = string.Empty;

if (contextKey == "U")
{
value = DateTime.UtcNow.ToString();
}
else
{
value = String.Format("{0:" + contextKey + "}", DateTime.Now);
}
return String.Format("<span style='font-family:courier new;font-weight:bold;'>{0}</span>", value);


}
}
}


Thankyou very much for posting this code.

I have worked through the differences between your version of the tutorial and the code I was trying to get running. It all boiled down to the name of the parameter on the web service method. I don't understand this yet but if I call the parameter on my web service method, "contextKey" it works, if I call it anything else, it fails.

Is anyone able to shed some light on this for me?


In the documentation it states that the paramater must be astring namedcontextKey

[WebMethod]string DynamicPopulateMethod(string contextKey) { ... }

Note you can replace "DynamicPopulateMethod" with a naming of your choice, but thereturn type and parameter name and type must exactly match, including case.

Problem Deploying ASP .NET Atlas on Vista Beta 2.

Hi Everyone,

I have a problem installing the Atlas June CTP on Windows Vista Beta 2 (Build 5384). It always pops an error: "C:\Program Files\Microsoft ASP .NET\Atlas\v2.0.50727\VSISetup.InstallState is denied" and subsequently rolls back the installation.

Please help!!! :(

Hey All,

I forgot to add, the user under which I tried installing Atlas belongs to the Administrators group...

Thanx...


I am having the exact same problem, same version of Vista and user in adminstrators group.

Problem displaying values in gridview using ajax

hi

I am using asp.net 2.0 version.and sql2005 database.

On my UpdateErrorLog.aspx page i have three dropdown.2nd dropdown is filled on basis of first and 3rd dropdown is filled on basis of second.On 3rd dropdown "onchange" event i have called javascript function"FetchDGContents()" defined in "AjaxScript.js" file using ajax.Ajax Request is send to page"AjaxServer.aspx" and i get the response from that page.Problem is coming when i am trying to use that response to display the data in gridview.Below i am writing the code for Ajax page,Design page and the javascript file.Error is mentioned in javascript file in FunctionFilltable() andCleartable().I have searched and found ,that the control name on page rendering is prefixed with its container name.So u can see in my code and in Javascript file the prefixed name is'ctl00_contentarea'.It is working fine for Dropdowns when i am accessing their values(below in code file u can see) but failed to do so for Gridview.Plz help me out.

Thanks is advance

Below Code ofUpdateErrorLog.aspx file-------

<%@dotnet.itags.org.PageLanguage="C#"MasterPageFile="~/Site.master"AutoEventWireup="true"CodeFile="UpdateErrorLog.aspx.cs"Inherits="UpdateErrorLog"Title="Untitled Page" %>

<asp:ContentContentPlaceHolderID="contentarea"Runat="Server">

<scriptsrc="js/filldropdown.js"type="text/javascript"></script>

<scriptsrc="js/AjaxScript.js"type="text/javascript"></script>//This is the file in which Prblem is coming

<divid="Headingtxt"class="containerheading">

Update Error Log</div>

<divid="formcontent"class="containerdiv">

<tablecellpadding="0"cellspacing="0"class="labelfont">

<tr>

<tdstyle="width: 65px; height: 30px">

<asp:LabelID="Label1"runat="server"Font-Names="Arial"Font-Size="X-Small"

Text="Project"></asp:Label></td>

<tdstyle="width: 100px; height: 30px">

<asp:DropDownListID="ProjectDropDown"runat="server"Width="179px">

</asp:DropDownList></td>

</tr>

<tr>

<tdstyle="width: 65px; height: 29px">

<asp:LabelID="Label2"runat="server"Font-Names="Arial"Font-Size="X-Small"

Text="WBS"></asp:Label></td>

<tdstyle="width: 100px; height: 29px">

<asp:DropDownListID="WBSDropDown"runat="server"Width="178px">

</asp:DropDownList></td>

</tr>

<tr>

<tdstyle="width: 65px; height: 34px;">

<asp:LabelID="Label3"runat="server"Font-Names="Arial"Font-Size="X-Small"

Text="Task"Width="32px"></asp:Label></td>

<tdstyle="width: 100px; height: 34px;">

<asp:DropDownListID="TaskDropDown"runat="server"Width="178px">

</asp:DropDownList></td>

</tr>

<tr>

<tdstyle="width: 65px; height: 28px">

</td>

<tdstyle="width: 100px; height: 28px"align="left">

<asp:ButtonID="BtnGo"runat="server"Text="Go"Width="47px"/></td>

</tr>

</table>

</div>

<divid="gridviewcontent"style="left: 175px; width: 515px; position: absolute; top: 265px;

height: 84px">

<asp:GridViewid="gverrorlog"style="Z-INDEX: 102; LEFT: -6px; POSITION: absolute; TOP: 1px"runat="server"

width="592px"CellPadding="3"GridLines="Both"BorderStyle="Inset"Font-Names="Arial"Font-Size="X-Small"Height="100px">

<HeaderStyleCssClass="colhead"BackColor="#FF8080"Font-Names="Arial"Font-Size="X-Small"></HeaderStyle>

<RowStyleBackColor="#FFC0C0"Font-Names="Arial"Font-Size="X-Small"/>

</asp:GridView>

<TABLEid="imgtbl"style="VISIBILITY:hidden"borderColor="#000000"cellSpacing="1"cellPadding="1"

width="96"bgColor="#ffffff"border="0">

<TR>

<TD></TD>

</TR>

</TABLE>

</div>

</asp:Content>

-------------------------------------------

Code forAjaxserver.aspx page----------

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.Data.SqlClient;

publicpartialclassAjaxServer : System.Web.UI.Page

{

#region Variables

SqlConnection con =newSqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);

CommonClass objcommon =newCommonClass();

ErrorLogClass objerrlog=newErrorLogClass();

DataSet SelectLogDS =newDataSet();

string chString;

#endregion

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!IsPostBack)

{

//getting querystring value from update errorlog page

string pid = Request.QueryString["PID"];

string wbsid = Request.QueryString["WBSID"];

string tid = Request.QueryString["TID"];if(Request.QueryString["FromUperrpage"]!=null)

{

Response.Clear();

SelectLogDS=objerrlog.SelectErrorLog(pid, wbsid, tid); //SelectErrorLog is the method defined in a class.

//If you want to test by showing the "Image for Process" for a long time, uncomment the below two lines and set the time

//Dim th As System.Threading.Thread

//th.Sleep(200)

chString = SelectLogDS.GetXml();

Response.Clear();

Response.ContentType ="text/xml";

Response.Write(chString);

Response.End();

}else

{

Response.Clear();

Response.End();

}

}

else

{

Response.Clear();

Response.End();

}

}

}

-----------------------------------

Code forAjaxScript.js ------------------------

// This creates a XMLRequest (ActiveXObject) to be sent to the server

var XmlReq;

function CreateXmlReq()

{

try

{

XmlReq =new ActiveXObject("Msxml2.XMLHTTP");

}

catch(e)

{

try

{

XmlReq =new ActiveXObject("Microsoft.XMLHTTP");

}

catch(oc)

{

XmlReq =null;

}

}

if(!XmlReq &&typeof XMLHttpRequest !="undefined")

{

XmlReq =new XMLHttpRequest();

}

}

//This fucntion is to send the choice into the AJAX Server page for processing

function FetchDGContents()

{

//Starts displaying the Process Image table

imgtbl.style.visibility ='visible';var requestUrl ="AjaxServer.aspx?FromUperrpage=true&PID=" + document.getElementById("ctl00_contentarea_ProjectDropDown").value +"&WBSID=" + document.getElementById("ctl00_contentarea_WBSDropDown").value +"&TID=" + document.getElementById("ctl00_contentarea_TaskDropDown").value;

CreateXmlReq();

if(XmlReq)

{

XmlReq.onreadystatechange = HandleResponse;

XmlReq.open("GET", requestUrl,true);

XmlReq.send();

}

}

function HandleResponse()

{

if(XmlReq.readyState == 4)

{

if(XmlReq.status == 200)

{

// Before filling new contents into the DataGrid, clear the cotents by calling this function

//ClearTable();

// Fill the cleared Datagrid with new XML Reponse

FillTable(XmlReq.responseXML.documentElement);

// Hides the Process Image Table after displaying the contents

imgtbl.style.visibility ='hidden';

}

else

{

alert("There was a problem retrieving data from the server." );

}

}

}

//Fills the datagrid contents with the newly recieved Response content

function FillTable(serrorlog)

{

// Gets the response XML

var errlog = serrorlog.getElementsByTagName('NewDataSet');

// Gets the table type content present in the Response XML and gets the data into a variable tbl

var tbl = document.getElementById('ctl00_contentarea_gverrorlog').getElementsByTagName("tbody")[0];//Getting Error on this Line Error is: "Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object"

// Iterate through the table and add HTML Rows & contents into it.

for(var i=0;i<errlog.context.childNodes(0).parentNode.childNodes.length;i++)

{

// Create a HTML Row

var row = document.createElement("TR");

// Set the style

row.setAttribute("className","text");row.setAttribute("bgColor","#ECECEC");

// Iterate thorugh the columns of each row

for(var j=0;j<errlog.context.childNodes(0).childNodes.length;j++)

{

// Create a HTML DataColumn

var cell = document.createElement("TD");

// Store the cotents we got from Response XML into the column

cell.innerHTML = errlog.context.childNodes(i).childNodes(j).text;

// Append the new column into the current row

row.appendChild(cell);

}

// Append the current row into the HTML Table(i.e DataGrid)

tbl.appendChild(row)

}

}

// Clearing the existing contents of the Datagrid

function ClearTable()

{

var tbl = document.getElementById('ctl00_contentarea_gverrorlog').getElementsByTagName("tbody")[0]; //Getting Error on this Line Error is: "Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object"

var row = tbl.rows.lengthfor (var i=1,j=1;j<row;i++,j++)

{

if (tbl.rows.length == 2){i = 1;}

tbl.deleteRow(i);

if (tbl.rows.length == i) {i = 0;}

}

}

-----------------------------------

u cant access objects of a page by id in separate javascript file

try palacing the code in the aspx page in <Script> tag or

u need to send object of that control to javascript function


Its also not working if we write the code in aspx page instead of placing in seperate js file.

I am still getting same error.

thanks


document.getElementById('ctl00_contentarea_gverrorlog').

instead try using

document.getElementById('<%=Controlid.clientid %>').

i think Controlid is contentarea_gverrorlog


can you please tell me what is clientid in the above code?

i have tried using document.getElementById('<%=Controlid.clientid %>'). but same error is coming.At runtime

it is showing this statement as "document.getElementById('System.Web.UI.WebControls.GridView')"

thanks


Client Id is id of that contol on client side like "ct100_gridview1"

use like this if u have a problem

in javascript which is in the same aspx page that has control

document.getElementById('<%= Id %>').

and Code behind like this

publicpartialclassDisabling_controls : System.Web.UI.Page

{

//Declare Page level global variable

Public String Id=String.Empty;

protectedvoid Page_Load(object sender,EventArgs e)

{

Id = GridView1.ClientID.ToString();

}


Your suggested code is working fine.but still error is coming on the same line i.e

----var tbl = document.getElementById('<%= Id %>').getElementsByTagName("tbody")[0];

if i remove "getElementsByTagName("tbody")[0]" i get the varaible "tbl" valuenull and If I don' t remove

i get the above said error.I am unable to track why error is coming because this code is working fine

in .Net 1.0 version using datagrid.No solution till now...

this is the function in which error is coming...

function FillTable(serrorlog)

{

// Gets the response XML

var errlog = serrorlog.getElementsByTagName('TestErrorLog');

// Gets the table type content present in the Response XML and gets the data into a variable tbl

var tbl = document.getElementById('<%= Id %>').getElementsByTagName("tbody")[0];

// Iterate through the table and add HTML Rows & contents into it.

for(var i=0;i<errlog.context.childNodes(0).parentNode.childNodes.length;i++)

{

// Create a HTML Row

var row = document.createElement("TR");

// Set the style

row.setAttribute("className","text");row.setAttribute("bgColor","#ECECEC");

// Iterate thorugh the columns of each row

for(var j=0;j<errlog.context.childNodes(0).childNodes.length;j++)

{

// Create a HTML DataColumn

var cell = document.createElement("TD");

// Store the cotents we got from Response XML into the column

cell.innerHTML = errlog.context.childNodes(i).childNodes(j).text;

// Append the new column into the current row

row.appendChild(cell);

}

// Append the current row into the HTML Table(i.e DataGrid)

tbl.appendChild(row)

}

}


see view source to check whether datagrid is rendered with

tbody

tags for which you are searching


I m using gridview .In starting i have mentioned that i m working in .Net 2005.

in .Net 2003 the same code is working fine for datagrid.But as in .Net2005 i m using master

pages and therefore control name on rendering gets changed(which is not so in .Net2003).

Same code work fine in .Net2005 if i dont use master pages in my project.

thanks


hi

i got it! where the problem is.Problem i am not showing data in gridview on pageload that's why

the error is coming, because gridview is not rendered onpageload and i am trying to access it...

But then next problem is How to Do paging,sorting,and to define userdefined tempaltes if we use AJAX.

If there is some solution realted to this please give me.I m working in .Net 2005(gridview control).

thanks a lot for all ur help.


That's why i have asked u to see ViewSource whether it is rendered or not

Problem getting AJAX work on content page

Hi,

I want AJAX - enable existing content ASP .NET page. After updating web.config all seemed OK. But ...

I'm still getting full postback even on this simple testing page:

<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="server">
<asp:UpdatePanel ID="upd1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:Label ID="Label1" runat="server" Text="Label"><%# DateTime.Now.ToString()%></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

As you guess ScriptManager is on master page and I left its properties default.

Any idea what am I missing?

You are missing your triggers!!!!

<triggers>

<asp:AsyncPostBackTrigger controlID="NameofYouControl" EventName="NameofEventThat triggers refresh"> </<asp:AsyncPostBackTrigger>

</triggers>


You are missing your triggers!!!!

<triggers>

<asp:AsyncPostBackTrigger controlID="NameofYouControl" EventName="NameofEventThat triggers refresh"> </<asp:AsyncPostBackTrigger>

</triggers>


<triggers></triggers> goes after <ContentTemplate></ContentTemplate>


Triggers shouldn't be needed in that example... There must be something wrong with the web.config, other code on the page, or possibly a configuration issue in IIS.


i would say it's the web.config issue.

Problem in Ajax i My ASP.Net WebSite

hi

i am working on my website.(when i created website,i don't select Ajax Enabled Template and it is a default asp.net website)

and i want add ajax feature to my website by drag ScriptManager and UpdatePanel from toolbox.but when i run my website,error shown in IE statusBar.

how to solve my problem ?

should i create new website as Ajax enabled template ?

thanks

Hello,

Make sure you install Ajax on your system, and you need to modify your web.config file.

The best way to modify the config file is, create new ajax project, which will built a web.config file for you.

You then compare your old web.config file with the ajax website web.config file. If you haven't added any information to your old web.config file, I would just copy the ajax web.config file to your current (web) project. And if you already added information into your web.config file, then just copy whatever you don't have from the ajax web.config file to yours.

I hope you understand what I'm talking about =)

WS

Wednesday, March 21, 2012

Problem in deployment of AJAX enabled website

Hello Everybody:

Recently I have installed ajax extension in VS2005. I have a asp.net 2.0 website and I made necessary change in the web-config file for the ajax extension as described in AJAX video tutorial in this website. It works fine but when I deploy it to my server then it finds error in web-config file related to missing dll. What can I do? Please give me a suggestion.

Thanks to all.

The ajax installer puts the dlls into the GAC. Because of this, they do not deploy with your app in the bin folder.

You need to also install ajax on the server you are deploying to.


Well, the only things you can do are:

Install the Ajax Extensions on your server! If it is a shared hosting company contacting them may help: I succeeded once -- BUT ONLY ONCE!
The other solution it to copy over: System.Web.Extensions.dll, System.Web.Extensions.Design.dll from C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025 into your bin folder and it should work if your application runs in full trust mode!

Hope it works!


I was able to deploy my ajax app on my server without installing anything, just putting the System.Web.Extensions.dll into the bin folder and referencing it. I am still unable to get the control toolkit to work without installing anything on the server. Any ideas on that?(Sorry, I know it's not the control toolkit forum, but the question fits perfect in this post :) )

Problem in invoking Webservice in ATLAS.Application

Hi Everybody,

Im facing problem in calling Webservice in ASP.NET ATLAS Page.Im trying to invoke a Webservice which is external to my system , in my application as follows:

<atlas:ScriptManagerID="NamSpacescriptManager"EnableScriptComponents="false"runat="server">

<Services>

<atlas:ServiceReferencePath="SimpleService.asmx"/>

<atlas:ServiceReferencePath="http://www.xmlwebservices.cc/ws/v1/calc/SimpleCalc.asmx"/>

</Services>

</atlas:ScriptManager>

function OnAddServiceClick( )

{

var response = SimpleCalc.Add(3,3,Oncomplete,OnTimeOut,OnError);

returnfalse;

}

in this above case, I went thru the WSDL and found the name of Class as SimpleCalc hence was trying to invoke the method ADD , May i know what is wrong in this ,

Or is it ATLAS doesnt support mechanism to invoke a webservice other than local system.

I would also like to know internally how ATLAS is invoking the Webservices, ie, Proxy classes ., how is it done .,

Thanks & Regards

Lohita

It looks like you might have neglected to instantiate the web proxy object in your Javascript, as in the following manner:

var calcSvc = new SimpleCalc();

var request = calcSvc.Add(...);


Is that something new? Because in the February CTP, I was just calling WebMethods like ..
var request = SimpleCalc.Add(...) and it was working fine. I'm about to try instantiating it now, but
I'm wondering again, if that's new .. or if something stranger is going on.

No, this has not changed, and you don't need to instantiate it.

Calling cross domain services is tricky, as it runs into browser security limitations. If the other server is also running Atlas, the March release has some support to make it work. If not, you should look into the new bridge feature (see Atlas docs and samples for details).

thanks,
David


I was actually wrong in my previous post. Your problem here is that you cannot make a web service call to a domain other than that which your page comes from. In order to do this, you must "bridge" the call through your web server using the new Bridge functionality added to the March CTP.

Hi David,

What do you mean by "If the other server is also running Atlas.." Does it mean the external webservice which we call using bridge feature should also have Microsoft.Web.Atlas.dll in its bin directory?

Thx, Vishant


No, I was referring to the ability to call services on a different server directly from the client. The bridge feature always goes through your Atlas server, and has no restrictions on what other servers it can bridge to.

David

problem in linking ASP.Net to Dojo

how can I link ASP.Net to Dojo?

Hi aidaerf,

Please check out these links:

Dojo toolkit with ASP.NET 2.0

Using Dojo and ASP.NET

Someone has done this.

Best Regards