Showing posts with label toolkit. Show all posts
Showing posts with label toolkit. Show all posts

Wednesday, March 28, 2012

Calling a server side function from client side using the toolkit

Ok, I'm sure this is a really stupid question, but I'm willing to ask it anyway.

Let's say that I created a new extender called "My", so I now have three files files, MyExtender.cs, MyBehaviour.js, and MyDesigner.cs.

I want my control to be able to take some data on the client side and use it to retrieve some data on the server side, which AJAX is all about right? :) So for the sake of argument, let's say I want to enter an email address in a textbox, and then consult a database to return the user's password.

So in my MyExtender.cs file, I create a function something like this:

public string getPassword(string email) {

... Make some database calls to get the info

return password;

}

What code do I put into the MyBehaviour.js file in to to call the getPassword function? And do I need any special decorations on the getPassword() function to make it happen?

You can use ICallbackEventHandler interface for this purpose. This is the exact purpose of this interface in ASP.Net 2.0. Check out the MSDN for this interface.


You really should look at how to create an extender to do it the best way. There is a great tutorial here,http://www.asp.net/ajax/ajaxcontroltoolkit/samples/Walkthrough/CreatingNewExtender.aspx that is a simple example of how to create a simple extender. Also if you just want to use the code behind to retrieve info from the database, you may just want to wrap an update panel around your form and get the data from the code behind. Either way you will be able to accomplish what you want.

Saturday, March 24, 2012

Call Animation versus hooking an event

I'm looking for a way to perform an animation on a dynamically defined object.

For instance...Let's take the Toolkit demo animation where a dialog flies out from a button and the button is grayedout.

Assume there is a page that has a list of items and each item has an associated More... button. What I would like is to be able to call a function when I click the More... button that would pass the button and div to the AE that I want to flyout . This would prevent me from having to code an AE block for each item and hardcode the name of the control I want to hook for the onClick event. In the end I'm trying to accomplish two primary things: 1) Avoid writing the AnimationExtender block for every item by hand and hard coding the id of the link/button and the div tag [This would also reduce page size]. 2) Avoid writing a function in the code behind that has to programatic create the AE blocks [Avoiding this would increase speed of rendering].

Is this possible with the current functionality of the AE or would it require a rewrite?

Hi there,

I am also trying to do something on the same lines as you just mentioned. I just wanted to know if you were able to do the above mentioned task. Kindly let me know if you have any information about how this can be done.

Thanks in advance,

Cheers

Vishy


I have not been able to accomplish anything to this date. I have currently put it on the back burner pending more time to work on it.

Wednesday, March 21, 2012

CalendarExtender Position

I am trying to use the CalendarExtender Control in my existing VB.net web application .

Downloaded the latest version of Ajax toolkit and included in the project.

I am using the control inside a Table as below..

My page is too long to fit in a screen. so this date field is at the bottom of the page. So if i scroll the page and selects this calender control,

the postion is lost. popup shows somewhere else. Also this control goes under the ListBoxes which is already there in the page.

What should i do to make the popup calender appear on the relative postion of the TargetControl and on top of other controls ?

In the documentation it says popupup should appear with the targetcontrol ..

<TD>

<asp:textboxid="_dt"runat="server"cssclass="data"columns="16"maxlength="16"></asp:textbox>

<asp:labelid="Label70"runat="server"cssclass="label3"text="(dd-mon-yyyy hhmm)"></asp:label>

<asp:ImageButtonid="btn_dt"Runat="server"ImageUrl="calendar.jpg"CausesValidation=false></asp:ImageButton>

<ajaxToolkit:CalendarExtenderID="calendarButtonExtender"runat="server"TargetControlID="_dt"

PopupButtonID="btn_dt"Format="dd-MMM-yyyy hhmm"/>

</TD>

THanks

-Roopa

Hi Roopa1,

roopa1:

Also this control goes under the ListBoxes which is already there in the page.

To resolve this , you should reference to thez-index.

roopa1:

Showing position issue.

I have tested it with a your code and add blank <tr> above the CalendarExtender. And it works fine on IE7 and Firefox. So would you please provide a simple sample here?

Hope this help.

Best regards,

Jonathan