Showing posts with label call. Show all posts
Showing posts with label call. Show all posts

Wednesday, March 28, 2012

ajax beta 1.0 run well in firefox 2.0 , but does not work in IE6 SP1 (winXp or win2000)

I migrate my company website form atlas to ajax beta 1.0 ,but there are script erros in IE6 SP1 (winXP or win2000) when I call web serviece from javascript.the

win2000 OS is updated to SP4 and the winXP OS is updated to SP1,but ajax does not run. when some winXP pc OS is updated to SP2,ajax run well.

By compared, ajax run well in firefox 2.0.

there are many IE users who need my help to run my website ,but who can help me?

Hi,

ASP.NET team member, Chris Riccio has pointed that this problem maybe be caused by a bug in IE 6 SP1 concerning to HTTP compression. In fact, I was able to fix it installing the patch KB912812 on the clients.

AJAX Beta 1 and PageMethods Error

Hello,
I'm using the PageMethods to call page methods. All works with the ATLAS CTP.
With the new AJAX Beta 1 I have an error: PageMethods is undefined. I don't think it's a problem of my web.config. If i create a new ASP.NET AJAX Enabled Web Site I have the same error.

Someone have the same error? Is it a bug? Is it a beta 1 change?

Thanks,
Alessadro

hello.

make sure that your page method is public and STATIC (this is a change from the previous ctp version). btw, make sure that the method receives all the values that it needs to perform its calculations since now you don't get access to the controls maintained on the page.


I have checked all this things before posting.
My methods are public and static and have the attributes Microsoft.Web.Script.Services.ScriptMethod and WebMethod.
They use only local variables and don't access any page controls.

I think that the error is different: PageMethods is undefined. I have this javascript error, so I don't think it's a problem with my methods. It's the PageMethods that is not defined.
If i define a simple method that return an integer, I have the same error. And I have the same error if i create a new ASP.NET AJAX Enabled web site project too.


hello again.

if i recall correctly, you just need to use the webmethod. here's a quick example i have here:

<%@. Page Language="C#" %>
<%@. Import namespace="LivroAtlas"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
[System.Web.Services.WebMethod]
public static Aluno[] ObtemAlunos()
{
Aluno[] alunos = new Aluno[]{
new Aluno( "João", 15 ),
new Aluno( "Rita", 16 ),
};

return alunos;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="manager" />
<input type="button" value="invocar método da página" onclick="handle()" />
</form>
<script type="text/javascript">
function handle()
{
PageMethods.ObtemAlunos( handleCallback);
}
function handleCallback( res )
{
for( var i = 0; i < res.length; i++ )
{
alert( res[i].Nome + "-" + res[i].Idade );
}
}
</script>
</body>
</html>

btw, if you check the source of your page and don't see the global variable PageMethods, then that means that the ScriptManager is not injecting the proxy for the methods on the client side...


Finally I resolved the problem.
The solution is describe in this post from Shawn Burke's Blog. Due to a bug in this release of AJAX the page method must be in the same ASPX Page and not in codebehind.


Did you do anything to get the PageMethods object to appear on your page?

I've got public static void, I've got WebMethod and ScriptMethod, and I've got the function in the page rather than the code-behind... still nothing.


what the.......

okay... apparently closing the project, leaving it overnight, and changing absolutely nothing... fixed it... what do ya know. :p


This will break too much of my code...I think I will revert back to ATLAS until this is resolved/changed.

Ajax based custom control with web service

I want to create a simple reusable search pane control.

The idea is to have a textbox and a button. When you press the button you trigger an AJAX call to the server with the textbox value as parameter. The AJAX call then bridge the request to a web service that perform the database search an return a dataset. The dataset is then binded to a repeater in a updatepanel to display result. I've been using a WCF service for the web service.

This work fine if I host the textbox, the button and the result detail ascx file in a ASP.NET Ajax Enabled WebSite.

I try to move this part to a user web control, including the ascx files in resources. I hit the following problem: When I include the control (compiled assembly) in a ASP.Net Ajax Enabled Web site, the control display correctly but the AJAX call fail.

I think that the ScriptManagerProxy setting the AJAX service in my user control fails to find the path of the asmx ServerScript definition within the assembly.

Do you have any idea to make this work smoothly, ideally with only the assembly included in the website project?

Thanks in advance for your help

mavrj

Web user control is not only an assembly, which should include .ascx file and.ascx.cs or.ascx.vb file.There is only one asp:ScriptManager in a Ajax web form. I once tested a Ajax enabled web user control and placed it in a common web form.I found it worked fine. Can you post some codes here? We are going to test it.

Monday, March 26, 2012

Ajax Asynchronous call

Hi

Can any one tell me how many asynchronous call can we make from an ajax webpage.I mean to say that if we are using update panel to implement any ajax functionality then how many maximum update panels can we put on our webpage along with one timer control extender for each update panel.Is there any limit for that?

In my application if i am using two update panels then the application refreshes the page without postback, but if i add third update panel control to the page and use timer extender to refresh then the page refreshes with postback.Please help me out in solving the issue..


Hi,

As far as I know, IE allows 2 simultaneous connections at maximum.


Priyank Joshi:

but if i add third update panel control to the page and use timer extender to refresh then the page refreshes with postback

But this issue doesn't seem to be related with the connection limitation. Can you show me a simple sample page of the issue?

Saturday, March 24, 2012

ajax and linkbutton problem, it is difficulty ,i cannot resolve it , help me

I use Asp.net Ajax exten1.0 encounter some question,so I need your help

My problem is :

I use two UpdatePanel in one aspx ,we can call left panel ,and right panel

At right panel ,I need to automatism make a server table ,and in every table cell ,I must bind a linkbutton in there , as linkbutton , the linkbutton text data is from database, linkbutton bind it ,and linkbutoon commandArgument are bind data also ,

now , I encounter problem is , when I click linkbutton , but not trigger linkButton _command this Event ,so I cannot get commandArgument value.to diplay at updatepanel1 ,but ,I assurance I register this Event , when the linkbutton automatism make ,sure I use this method

eg:

lnkButton =New LinkButton() ' add Event

AddHandler lnkButton.Command,AddressOf lnkButton_Command

eg : add trigger

Dim trigger As AsyncPostBackTrigger = New AsyncPostBackTrigger() trigger.ControlID = lnkButton.ID UpdatePanel2.Triggers.Add(trigger) I Add tirggers but , in html source I cannot find like these code , Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1','tUpdatePanel2'], ['btnConfrim','CalendarSelect','k0_0_0_0','k0_0_0_1','k0_0_0_2','k0_0_0_3','k0_0_1_0','k0_0_1_1','k0_0_1_2','k0_0_1_3','k0_0_2_0','k0_0_2_1','k0_0_2_2','k0_0_2_3','k0_0_3_0','k0_0_3_1','k0_0_3_2','k0_0_3_3','k0_1_0_0','k0_1_0_1','k0_1_0_2','k0_1_0_3','k0_1_1_0','k0_1_1_1','k0_1_1_2','k0_1_1_3','k0_1_2_0','k0_1_2_1','k0_1_2_2','k0_1_2_3','k0_1_3_0','k0_1_3_1','k0_1_3_2','k0_1_3_3','k0_2_0_0','k0_2_0_1','k0_2_0_2','k0_2_0_3','k0_2_1_0','k0_2_1_1','k0_2_1_2','k0_2_1_3','k0_2_2_0','k0_2_2_1','k0_2_2_2','k0_2_2_3',This 'k0_2_0_3' is linkbutton ID , That is why , thank you for your help

Your English is a bit shaky, so it was difficult to decipher exactly what is going on. However, one thing for sure that you are doing wrong is that you cannot create triggers programmatically. That is stated in the UpdatePanel Class page. If you simply use the ChildrenAsTriggers property set to true which is default, then when a link is clicked it will trigger the UpdatePanel update. However the issue of the command argument not available can be a bit more complex. It depends on the order of events and that is too complex to anayze without a simplified version of your code posted here. (Use the code editor button above to paste it a bit more neatly).

An example of why this might be necessary is that the order of page events can be affected by what is done during the page life cycle. For example I have seen the order of 2 events reverse simply by doing a FindControl or not in a method. There are muliple points in the life cycle where a control can Bind for instance and it may in fact Bind multiple times without you knowing it. That's just the way it works.

I would suggest that you add a Trace to all relevant events and check the order of events as that can sometimes give you insight. I have a very complex GridView run in Ajax, and without Trace events, I never would have been able to figure out what was wrong during edit with 2 way binding templates, column re-ordering, multi-column sorting, paging, etc all of which occur with Ajax.


sorry , my english is very poor.

my code is :

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load createTable()End Sub'Public Sub createTable()For iAs Integer = 0To 5Dim rowAs TableRow =New TableRow()For jAs Integer = 0To 6Dim cellAs TableCell =New TableCell() cell.Controls.Add(CreatePerSolt(i, j)) row.Controls.Add(cell)Next tabShecule.Controls.Add(row)Next End Sub Public Function CreatePerSolt(ByVal iAs Integer,ByVal jAs Integer)As TableDim tabAs Table =New Table tab.ID = i &"_" &"_" & jFor kAs Integer = 0To 3Dim rowAs TableRow =New TableRow()For hAs Integer = 0To 3Dim cellAs TableCell =New TableCell() lnkButton =New LinkButton() lnkButton.Text ="k" & i &"_" & j &"_" & k &"_" & h lnkButton.ID ="k" & i &"_" & j &"_" & k &"_" & h lnkButton.CommandArgument ="k" & i &"_" & j &"_" & k &"_" & hAddHandler lnkButton.Command,AddressOf lnkButton_CommandDim triggerAs AsyncPostBackTrigger =New AsyncPostBackTrigger() trigger.ControlID = lnkButton.ID trigger.EventName ="Click" UpdatePanel2.Triggers.Add(trigger) cell.Controls.Add(lnkButton) row.Controls.Add(cell)Next tab.Controls.Add(row)Next Return tabEnd Function Protected Sub lnkButton_Command(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.CommandEventArgs)Handles lnkButton.Command Label18.Text = e.CommandArgument.ToString()End Sub

I think you have to try this a different way to start.

http://www.asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_UpdatePanel.aspx

Please note the following statement:

You can add anUpdatePanel control programmatically, but you cannot add triggers programmatically. To create trigger-like behavior, you can register a control on the page as an asynchronous postback control. You do this by calling theRegisterAsyncPostBackControl(Control) method of theScriptManager control. You can then create an event handler that runs in response to the asynchronous postback, and in the handler, call theUpdate() method of theUpdatePanel control.

However because your table is inside the UpdatePanel, if you have ChildrenAsTriggers default set to true,all the LinkButtons should trigger an update without needing to register them. Just remove the trigger code. Once that is done if you still do not get a CommandArgument, post the UpdatePanel markup so that this can be duplicated.

Wednesday, March 21, 2012

Ajax and GridView Sorting or paging

Hello,

I have a main page , it's contain a call page with gridview (with features sorting and paging)

But when I click on link PAGE1, and I click on sorting, It's my page'myPageGridview.aspx' that load.

My aspx page

<head>

<title>Untitled Page</title>

<scriptlanguage=JavaScriptsrc="JavaScript/Ajax.js"></script>

</head>

<body>

<Aclass=parchemin_suite_linkonclick=javascript:show_entry('myPageGridview.aspx');href="#">Page 1</A>

<DIVid=parchemin_zonestyle="DISPLAY: none; LEFT: 102px; POSITION: absolute; TOP: 44px">

<Aonclick=javascript:hide_entry();href="#">Hidden page</A><DIVid=parchemin></DIV>

</DIV>

</body>

</html>

My Javascript page :

var ajax=false;

try

{

// All

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

}catch (e) {

try {

// IE

var MSXML_XMLHTTP_PROGIDS =new Array(

'MSXML2.XMLHTTP.5.0',

'MSXML2.XMLHTTP.4.0',

'MSXML2.XMLHTTP.3.0',

'MSXML2.XMLHTTP',

'Microsoft.XMLHTTP'

);

for (var i=0; i < MSXML_XMLHTTP_PROGIDS.length ; i++) {

try {

ajax =new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);

//alert(MSXML_XMLHTTP_PROGIDS[i]);

}

catch (e)

{

ajax =false;

}

}

}

catch (E) {

ajax =false;

}

}

// Mozilla / Safari

if (!ajax &&typeof(XMLHttpRequest)!='undefined') {

ajax =new XMLHttpRequest();

}

function getMyHTML(serverPage, objID) {

ajax.open("GET", serverPage);

ajax.onreadystatechange =function() {

//alert("Status : " + ajax.status);

if (ajax.readyState == 4 && ajax.status == 200) {

document.getElementById(objID).innerHTML = ajax.responseText;

document.getElementById('parchemin_zone').style.display='';

}

}

ajax.send(null);

}

function show_entry(entry_id)

{

getMyHTML(entry_id,'parchemin');

}

function hide_entry()

{

document.getElementById('parchemin_zone').style.display='none';

}

function view_entry()

{

document.getElementById('parchemin_zone').style.display='inline';

}

function ismaxlength(obj){

var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) :""

if (obj.getAttribute && obj.value.length > mlength)

obj.value = obj.value.substring(0, mlength)

}

nobody has idea ?

when I use an Autopostback, I have this error.

For exemple, I have a main page width 3 page include in Ajax.

when I use autopostback, my page reload width only my table.


Instead of using Ajax I would recommend that you use Atlas. What's the difference? Well Atlas is based on Ajax, at least the idea of Ajax anyway, but it does all the hard work for you. If you download the December release of Atlas (http://www.asp.net/default.aspx?tabindex=7&tabid=47) and visit this blog (http://www.nikhilk.net/AtlasM1.aspx) you will see how easy it is to use. It will virtually eliminate any XML or JavaScript that you have to write. But to answer you question directly. I have no idea what could be wrong with your code. I think that your question would be best served on an Ajax specific forum.

Good luck.

AJAX and Code Behind

i would like to do some code behind work along with javascript on my page. I have a modalPopup taht when the user clicks submit i want it to call the javascript function to alert the user and also call a function in my codebehind to insert so values into a database. when i added an OnClick to my button it never fires. Why?

You can handleBeginRequest to execute some JavaScript code as the partial postback initializes.


Hi,

This should work if you do not cancel the form submit event.

Please share your code for better understanding.


<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="iPort.master" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server" > <script type="text/javascript"> // JScript File var styleToSelect; function onOk() { alert('New portfolio created!'); } function Getnew() { var num = Math.ceil(Math.random()*10); var control = document.getElementById('Text7'); control.value = num; } </script> <br /> <br /> <p id="P1"> <table style="border-right: black thin solid; border-top: black thin solid; border-left: black thin solid; border-bottom: black thin solid" cellpadding="0" cellspacing="0"> <tr> <td colspan="5"> <asp:Button ID="New_iPort" runat="server" Text="New" Width="75px" OnClientClick="Getnew()" /></td> </tr> <tr> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> <strong> PortfolioID</strong></td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> <strong> PortInfo1</strong></td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> <strong> PortInfo2</strong></td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> <strong> PortInfo3</strong></td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> <strong> ActivePortfolio</strong></td> </tr> <tr> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> 1001</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> 1</td> </tr> <tr> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> 1002</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> 0</td> </tr> <tr> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> 1003</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> Data</td> <td style="width: 100px; border-right: black 1px solid; border-top: black 1px solid; border-left: black 1px solid; border-bottom: black 1px solid;"> 1</td> </tr> </table> </p> <p> <asp:Label ID="Label9" runat="server" Text="Label"></asp:Label> </p> <asp:Panel ID="Panel1" runat="server" Width="505px" CssClass="modalPopup" style="display:none;"> <div style="width: 100%; font-weight: bold; font-size: 14pt; text-align: center;">  New Portfolio <hr /> </div> <div style="width: 100%;"> <table cellpadding="0" cellspacing="1"> <tr> <td style="width: 100px"> <asp:Label ID="Label1" runat="server" Text="PortfolioID"></asp:Label></td> <td style="width: 100px"> <input id="Text7" disabled="disabled" type="text" /></td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 100px"> <asp:Label ID="Label2" runat="server" Text="PortData1"></asp:Label></td> <td style="width: 100px"> <input id="Text8" type="text" /></td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 100px"> <asp:Label ID="Label7" runat="server" Text="PortData2"></asp:Label></td> <td style="width: 100px"> <input id="Text9" type="text" /></td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 100px"> <asp:Label ID="Label3" runat="server" Text="PortData3"></asp:Label></td> <td style="width: 100px"> <input id="Text10" type="text" /></td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 100px"> <asp:Label ID="Label4" runat="server" Text="PortData4"></asp:Label></td> <td style="width: 100px"> <input id="Text11" type="text" /></td> <td style="width: 100px"> </td> </tr> <tr> <td style="width: 100px; height: 19px"> <asp:Label ID="Label6" runat="server" Text="PortData5"></asp:Label></td> <td style="width: 100px; height: 19px"> <input id="Text12" type="text" /></td> <td style="width: 100px; height: 19px"> </td> </tr> <tr> <td style="width: 100px; height: 19px"> <asp:Label ID="Label5" runat="server" Text="PortData6"></asp:Label></td> <td style="width: 100px; height: 19px"> <input id="Text13" type="text" /></td> <td style="width: 100px; height: 19px"> </td> </tr> <tr> <td style="width: 100px; height: 20px;"> <asp:Label ID="Label8" runat="server" Text="Active"></asp:Label></td> <td style="width: 100px; height: 20px;"> <input id="Checkbox2" type="checkbox" /></td> <td style="width: 100px; height: 20px;"> </td> </tr> </table> </div> <div style="width: 100%; text-align: center;"> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />   <asp:Button ID="Button2" runat="server" Text="Cancel" OnClick="Button2_Click" /> </div> </asp:Panel> <br /> <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender1" runat="server" TargetControlID="New_iPort" PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="Button1" OnOkScript="onOk()" CancelControlID="Button2"> </ajaxToolkit:ModalPopupExtender> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </asp:Content>

protected void Button1_Click(object sender, EventArgs e) { Label9.Text ="Submit button clicked!"; }protected void Button2_Click(object sender, EventArgs e) { Label9.Text ="Cancel Button clicked!"; }

Hi,

I am afraid it is normal,

ASP.NET render the two buttons as following:

<input type="submit" name="ctl00$SampleContent$OkButton" value="OK" id="ctl00_SampleContent_OkButton" />
<input type="submit" name="ctl00$SampleContent$CancelButton" value="Cancel" id="ctl00_SampleContent_CancelButton" />

Wether you add OnClick or not,it render the same, no postback is fired!

But you can fire the postback in the OkScript via javascript.That is the workaround.

Best Regards,


and how would one go about doing that?


hello.

for instance, you can call the __doPostBack method from your js code and set the target to the client id of your button.