Showing posts with label solution. Show all posts
Showing posts with label solution. Show all posts

Monday, March 26, 2012

pressing enter on a form in an updatepanel

Hi,

Im trying to fix my forms so that enter does not submit forms on IE/Mozilla/Safari but cannot find a solution. First off I used :

/*--- Disable enter key ----*/function kH(e) { var pK = e ? e.which : window.event.keyCode;return pK != 13;} document.onkeypress = kH;if (document.layers) document.captureEvents(Event.KEYPRESS);/*------------*/

on all pages but it didnt seem to work. So then I decided to try catch the keypress from forms like input and textarea and I used the following (onkeypress="return ifEnter(this,event);")

function ifEnter(field,event) { var theCode =event.keyCode ?event.keyCode :event.which ?event.which :event.charCode;if (theCode == 13) {return false; }else {return true; }}

but again it doesnt seem to work. Another thing I noticed is that it seems to submit the form as asp.net would. My default form submission is a next button which moves to another page when submitted, but when someone hits enter, the same page reloads with a standard postback i think.

What I want to know is why the javascript wont work? Is it because the form is in an updatepanel? How can I manage the user pressing enter in an update panel?

Why doesnt the user pressing enter activate the DefaultButton action of the panel which its in?

All help much appreciated!

C

Edit: never mind, I see the behavior now.

I saw the behavior with only one textbox. Adding a second set to invisible, perhttp://aspnet.4guysfromrolla.com/articles/060805-1.aspx, fixed it.

See if that helps for you.


My form allready had multiple textboxes etc.

The problem seesm to be only in firefox. Ive found a partial fix for my problem which at least submits my default button and saves the form instead of performing a callback here :

http://www.andornot.com/about/developerblog/2007/09/fix-firefox-defaultbutton-issue-with.aspx

Im still looking for a simple way to prevent enter key form posting back in certain textareas or input text boxes in firefox pretty please.

Saturday, March 24, 2012

Problem building the TemplateVSI project

I am attempting to build the TemplateVSI project in the AjaxControlToolkit solution. When I try I get this error:

Error 1 The process cannot access the file 'C:\Documents and Settings\randyd\Local Settings\Temp\tmp1E.tmp' because it is being used by another process. C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AJAX Control Toolkit\TemplateVSI\TemplateVSI.csproj 52 5 TemplateVSI

I can not find reference to this error relating to the TemplateVSI project anywhere.

Any help would be great!

Thanks,
Randy DeForest

Hi Rdeforest,

Have you installed the Ajax Control Toolkit template yet? Based on my experience, I think that you should restart your system and have a test. If your problem still cannot been resolved, we suggest that you should reinstall your Ajax Control Toolkit template by following the tutorial: http://www.asp.net/learn/ajax-videos/video-76.aspx .

Best Regards,

Jonathan


Thank you for the response.

I have un-installed and re-installed the AJAX Extensions. I get the same error when attempting to build the TemplateVSI, as instructed in the video.

I do not understand what you mean by the AJAX Control Toolkit template. Please explain. Also, the link you posted is to another, unrelated, post.

Thanks again for your response.

Randy


Hi Rdeforest,

Here is video tutorial for insatll Ajax Control Toolkit Template: http://www.asp.net/learn/ajax-videos/video-76.aspx

For get started with ASP.NET AJAX, please visit: http://www.asp.net/learn/ajax-videos/video-75.aspx

For more video tutorial, please visit: http://www.asp.net/learn/ajax-videos/ Embarrassed

Best Regards,

Jonathan


Jonathan,

As stated, I followed the instruction on the video. I was still unable to complete the build.

I re-installed VS2005 Team Suite and still received the same error.

I was able to get a copy of a previous version of the Control Toolkit, and it compelted the build without any issues.

Thanks for you help.

Randy

Problem in calling a Webservice in ATLAS Application.

Hi Every body im new to this community,

Im facing problem in calling the webservice from ATLAS Application .

If the WEbservice is in the same solution im able to do it, but when i create a new webservice and try to call in my ATLAS application im not able to do it,

Im getting following Error "

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

<Services>

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

<atlas:ServiceReference

Path=http://localhost:3505/SimpleCalculator/SimpleCalculator.asmx/>

</Services>

</atlas:ScriptManager>

<scripttype="text/javascript"language="javascript">

function OnAddServiceClick( )

{

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

returnfalse;

}

</script>

Im getting Error : SimpleCalculator , undefined, can i know what is wrong ...

Regards,

Hi,

The problem is that, a service reference to a web service causes an xmlscript reference in the generated page through a "/js" call to the web service.

If you examineCalling a simple Web Service from an ASPX page quick start sample, when you add
<atlas:ServiceReference Path="SimpleService.asmx" />
to your source, what is rendered as xmlscript is:
<references>
<add src="http://pics.10026.com/?src=SimpleService.asmx/js" />
</references>

Call SimpleService.asmx/js and you will get this piece of javascript:
Type.registerNamespace('Quickstart.Samples'); Quickstart.Samples.SimpleService = new function() { this.path = "http://atlas.asp.net/quickstart/atlas/samples/services/SimpleService.asmx"; var cm=Web.Net.ServiceMethodRequest.createProxyMethod; cm(this,"EchoString","s"); }

So, behind the scenes, Atlas client framework makes a call to the web service, asks the service to describe itself in javascipt and registers a function for you to call later from your code.

But there's no such default "/js" handler in web service world. Instead, Atlas provides necessary handlers in web.config to reply requests for "webservicename.asmx/js". That's why it works when your web service is in the same project with your Atlas GUI project.

If you enable the Atlas handler for .asmx files in your web service project as in your GUI project, it should work fine.

Wednesday, March 21, 2012

Problem in ListBox double click in UpdatePanel

Hi,

I have a problem in add ListBox double click in UpdatePanel. Now, my code works well.(It is the solution online) But when I put the ListBox in UpdatePanel, it also refresh the whole page, not AsyncPostBack...The dblclick is in Javascript, I don't how can it also work fine with AJAX. Thanks!

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %
<!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 language="javascript">
function ListBox1_DoubleClick() {
/* we will change value of this hidden field so

that in
page load event we can identify event.
*/
document.forms[0].ListBox1Hidden.value = "doubleclicked";
document.forms[0].submit();
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>Double click on Listbox
<br />
<asp:ListBox id="ListBox1"
ondblclick="ListBox1_DoubleClick()" runat="server">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
<asp:ListItem Value="4">Four</asp:ListItem>
</asp:ListBox>
<input type="hidden" name="ListBox1Hidden" />
</div>
<div>click on button
<br />
<asp:Button id="Button1" onclick="Button1_Click"
runat="server" Text="Button"/>
</div>
</ContentTemplate>
</asp:UpdatePanel>


</form>
</body>
</html>

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;

public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request.Params["ListBox1Hidden"] != null
&& (string)Request.Params["ListBox1Hidden"] == "doubleclicked") {
//This means It was double click
Response.Write("Double Click was fired selected item is "
+ ListBox1.SelectedItem.Text);
}

}
protected void Button1_Click(object sender, EventArgs e)
{

}
}

I think you should enablepartialrendering property of the ScriptManager.

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

Still not working.......any another idea? Thanks

codeasp:

I think you should enablepartialrendering property of the ScriptManager.

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


Instead of calling submit on the form, try __doPostBack('<%= UpdatePanel1.ClientID %>', '');


Thank you so much! It works now.