Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Saturday, March 24, 2012

Call a WebMethod from javascript (I dont want to use any server side buttons only javascri

I think my problem is slightly different.

I have defined a region of an image using jquery (javascript) I check the click event, it something like onclick for button, so as you can see its all javascript nothing server side button, etc

I want to load a .asmx dynamically in an update panel. I know how to do this using a link button. Now what I want to do is to call a method that load this file in my server code behind.

This is what I tried to do so far. I simplified the problem.

' <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
<Scripts>
<asp:ScriptReference Path="JavaScript/loadmypages.js"/>
</Scripts>
</asp:ScriptManager>

'

loadmypages.js is a simple javascript that call my function (i am hoping that it will) through PageMethods. this is a simple style of my javascript.

'

// JScript File

var Load_content2 = function()
{
PageMethods.myfunction_on_code_behind(OnComplete1, OnTimeOut1, OnError1);
return false;
}

function OnComplete1(result)
{
alert(result);
}

function OnTimeOut1(result)
{
document.getElementById('lblMsg').innerHTML ="Time out";
}

function OnError1(result)
{
document.getElementById('lblMsg').innerHTML ="There is an error!";
}

'

I have tried to make my method accesable for javascript like this:

'

using System.Web.Services;

[WebMethod]
[System.Web.Script.Services.ScriptMethod()]
public string myfunction_on_code_behind()
{
return "Its good if it works";
}

'

but every time i click on that region the script debugger say PageMethods is not defined.

Could someone help me to solve this problem ? am I missing something here ? as you can see I have even enabled page method: EnablePageMethods="true"

Thank you

Hi,

Please note that the method should be a static method.
Hope this helps.
Can you post your whole webservice file here? I think you are missing something.

Has there been any updates to MS Ajax that don't require PageMethods to use static methods yet?


No, nor would I expect one in the future.

Call a JS function on AJAX update (instead of using UpdateProgress control)

The atlas:UpdateProgress control is nice, but an app I am working on already has a "loading..." image that is displayed using JavaScript (displayLoader(), and hideLoader() to hide) whenever a "non-Atlas" postback is invoked, and when the page initially starts loading.

I am looking for an way to call these functions whenever an Atlas postback is made so I can use this functionality for both types of postback. Is there an way to do this with client script, rather than creating a custom version of the UpdateProgress control?

Regards,
David

You should check out the samples on the client atlas section.

You can handle the different events to create your own custom progress indicator.


hello.

once again, search the atlas discussion an suggestion forum. there you'll find 1 or 2 posts that show how to handle the propertychanged event of the pagerequestmanager in order to handle the start and end of a partial atlas postback with jscript.


Great, those keywords have helped turn up some good results. I was previously searching both here and search engines for terms relating to "custom atlas updateprogress control" and didn't have much luck.

Thanks for pointing me in the right direction.
Regards,
David

Wednesday, March 21, 2012

CalendarExtender throws error after manual textbox input

Hya,

I'm encountering a few issues with the calendarextender on the new RTM, i just have a textbox, a image, and the extender on a blank page:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:Label ID="lblPublishDate" runat="server" AssociatedControlID="publish_date" Text="Publish Date:"></asp:Label><br /><asp:TextBox ID="publish_date" runat="server" CssClass="frm_textbox" Width="150px" ValidationGroup="SearchLatestNews"></asp:TextBox><asp:Image runat="Server" ID="imCalendar" CssClass="vm" ImageUrl="/images/calendar.png" /><br /><em>e.g. 01 Jan 2007</em><ajaxToolkit:CalendarExtender ID="extCalendar" runat="server" TargetControlID="publish_date" PopupButtonID="imCalendar" />


The data format is dd MMM yyyy and i want to allow the user to manually input the data aswell as picking it. and i get the following error in both IE and FF:

Error: [Exception... "'Sys.ArgumentUndefinedException: Sys.ArgumentUndefinedException: Value cannot be undefined.
Parameter name: array' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no]

Is anyone experienced the same issue? Is there a known workaround?


Kind Regards,

P.

Sorry i was doing some tests, and i accidentally removed the format="dd MMM yyyy" from the code..

CalendarExtender question

I have a textbox, an image button and a calendar extender on my form. If I go with the default and don't make an entry for the PopupControlID attribute, the calendar gets displayed when the textbox gets focus and I can select a date from it. If I use the image button as the entry for the PopupControlID attribute, the calendar initially gets displayed but then the whole page posts to the server and returns before a date can be selected. There aren't any AJAX controls on the MasterPage and nothing in it's code-behind that would cause this issue. There also isn't currently any code-behind in my form ... just HTML ... and I'm posting it in its entirety below:

<%@dotnet.itags.org.PageLanguage="VB"MasterPageFile="~/MasterPages/MasterPage.master"AutoEventWireup="false"CodeFile="CalendarTest.aspx.vb"Inherits="Correspondence_CalendarTest"title="Untitled Page" %>
<%@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<asp:ScriptManagerrunat="server"></asp:ScriptManager>
<br/><br/>
<asp:TextBoxID="Date1"runat="server"></asp:TextBox>
<asp:ImageButtonID="ImageButton1"runat="server"ImageUrl="~/Images/Calendar_scheduleHS.png"/>
<cc1:CalendarExtenderID="CalendarExtender1"runat="server"TargetControlID="Date1"PopupButtonID="ImageButton1">
<%--
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Date1">
--%>
</cc1:CalendarExtender>

</asp:Content>

Why does this bloody thing insist on posting back to the server and is there anything I can do to prevent it from occurring?

TIA,

Allen

this is from another issue close to what you have because when you click the button a second time it does a post back as well. there is the solution from another post.

just to say, I've found this can be solved by creating a plain html img tag and assigning the popubbutton id to that instead of an asp imagebutton control


Did you make sure the CAUSESVALIDATION property of the Calendarextender is set to false? There is no problem using an asp:imagebutton control if you have that done. I mean that way when the Calendar control is clicked, all that happens is the control opens and selection is made.

Dollarjunkie