Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Wednesday, March 28, 2012

ContextKey is not a valid attribute of AutoCompleteExtender

So we need to use the ContextKey (and, by extension, UseContextKey) property with our project but it doesn't seem to in the actual control even though I've seen form posts in which people speak of using it. I also can't find any reference to the ContextKey being mothballed anywhere.

What gives? Where's thebeef ContextKey?

Hi,

Do you have the latest version of the Toolkit? Those properties were added pretty recently.

Thanks,
Ted


Yeah, that was the first thing I checked...

Hi,

I'm using 1.0.10618. And I can see Contextkey property is there.

Monday, March 26, 2012

ConfirmButtonExtender missing property?

Hi,

I'm currently using an AJAX Toolkit 3.5 ConfirmButtonExtender within a ListView (similar to a GridView, for those who know AJAX 1.0 better) and I've placed it within an ItemTemplate in order to confirm the deletion of an item.

<asp:ImageButton ID="deleteItemButton" runat="server" CommandName="Delete" ImageUrl="Images/Icons/user_delete.gif" ToolTip="Delete" />
<cc1:ConfirmButtonExtender ID="confirmButtonExtender" runat="server" ConfirmOnFormSubmit="false" TargetControlID="deleteItemButton" ConfirmText="Delete item?"></cc1:ConfirmButtonExtender>

This works fine, but when I decided to use a ModalPopupExtender together with the ConfirmButtonExtender, I saw that I had to DisplayModalPopupID of the ConfirmButtonExtender to the ID of the ModalPopupExtender. Simple enough - if only this property actually existed on the ConfirmButtonExtender. Perhaps this is something that's just been take away from v3.5 but existed in v1.0? Anyway, I attempted to work around this by not using a ConfirmButtonExtender at all and just linking the ModalPopupExtender to the deleteItemButton. The modal popup displays and hides fine, except that the command doesn't actually get executed. The code for my buttons within the panel shown by the ModalPopupExtender is:

<asp:Button ID="confirmDeleteButton" runat="server" CommandName="Delete" Text="Confirm" /><asp:Button ID="cancelDeleteButton" runat="server" CommandName="Cancel" Text="Cancel" />

Of course, these button IDs are specified via the OkControlID and CancelControlID properties of the ModalPopupExtender, but all to no avail. Could anyone please explain to me where this DisplayModalPopupID property has gone, and more importantly, the correct method to accomplish what I've explained using the AJAX Toolkit 3.5? Thanks...

Alex

Sorry, my mistake. I just realised this property was added to the newest version, which I didn't realise was more recent that mine.

Confirmbuttonextender doesnt work with button with usesubmitbehavior=false

Just more of a warning, if you use a standard button with a confirmbuttonextender and you have the usesubmitbehavior property set to false, the button will still cause the postback even though the messagebox shows to confirm the action. The postback does not wait for the messagebox to be dismissed.

Hi Jrod111,

Yes, if the UseSubmitBehavior="false" , it will send a postback no matter which button you choose. Let's find why.

When UseSubmitBehavior="true" (or not setted), the Button will generate these html code on the client page:

<input type="submit" name="Button" value="Click Me" id="Button" />

But when UseSubmitBehavior="false", the generated html code just like this:

<input type="button" name="Button" value="Click Me" onclick="javascript:__doPostBack('Button','')" id="Button" />

So that's the reason.

Best regards,

Jonathan


Im aware of how the usesubmitbehavior uses javascript, but the confirmbuttonextender attaches to the onclick event. Im guessing its handler fires after the _doPostBack() call, so it never gets intercepted. Maybe there is a tweak you can do to the extender to get its to intercept the onclick first and cancel it if necessary.

ConfirmButtonExtender - how to use ConfirmOnFormSubmit

Hi,

Can anyone please post a working example about how to useConfirmOnFormSubmit property ofConfirmButtonExtender ?

Thanks!

Here is a video tutorial on the extender.

http://www.asp.net/learn/ajax-videos/video-119.aspx


Hi,

I'd say ConfirmOnFormSubmit is either deprecated or was never implemented. I don't see it in my object browser. There's not much out there, other than this documentation which seems to be inaccurate:

http://asp.net/ajax/control-toolkit/live/ConfirmButton/ConfirmButton.aspx

It says:

ConfirmOnFormSubmit - True if the confirm dialog should wait until just before the form submits to display. This is useful when ASP.NET validators are in use and the confirm should be shown only after all validators pass.

Pete


Yes Pete. This is the only information I got from the web search.

I tried many time to use it because my project need to do the validation first and ONLY when the validation passed, we need show the confirmation popup.

Thanks anyway!


Within the Button properties, under theConfirmButtonExtender you must set theConfirmOnFormSubmit to'True'
Only then will the Pop-up only appear if validation has passed true.


Here is my code, the ConfirmOnFormSubmit DOES NOT work. Did I get it wrong? Apprecite your help!
TestConfirmButton.aspx 
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="TestConfirmButton.aspx.cs" Inherits="TestConfirmButton" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><!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"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> Enter an even number: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="TextBox1" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click" /> <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Warning!"ConfirmOnFormSubmit="true" TargetControlID="Button1" Enabled="True"> </ajaxToolkit:ConfirmButtonExtender> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></div> </form></body></html>

TestConfirmButton.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;public partialclass TestConfirmButton : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { Label1.Text =""; Label2.Text =""; }protected void Button1_Click(object sender, EventArgs e) { Label1.Text ="Saved!";// Display whether the page passed validation.if (Page.IsValid) { Label2.Text ="Page is valid."; }else { Label2.Text ="Page is not valid!"; } }protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) {try {// Test whether the value entered into the text box is even.int i =int.Parse(args.Value); args.IsValid = ((i % 2) == 0);//args.IsValid = false; }catch (Exception ex) { args.IsValid =false; } }}

Correct me, but are you trying to use the 'ConfirmButtonExtender' as a popup for the validation of the even number?


I just used the evaluation of the even number as an example to use the ConfirmButtonExtender's ConfirmOnFormSubmit.

The thing I wanted to achieve is:

The confirm message popups only when the number is even; if the number is odd, then don't popup the confirm message.

Is this do-able at all?

Thanks!


Hi,

The ConfirmOnFormSubmit property indicates that the ConfirmMessage will popup when the page is to be submitted. So, only the failure of client side validation( That's to say, you need to enable clientValidation for this customValidator. ) is able to prevent the form from being submitted, subsequently the ConfirmMessage won't be shown.

Now consider your situation, the confirm box has to be shown when the validation fails, which means the form isn't able to submit. It's a paradox. You may need to implement it withconfirm method.

Hope this helps.

Wednesday, March 21, 2012

Concurrency and EnableSession

Hi all.
I'm writing a web service to return data to a web page that use ajax to manage it.

I use the property EnableSession in WebMethod to enable the session and manage my authenticated user.

The problem is that my web service doesn't handle concurrent request and queue them.


Is there a way to make them concurrently?!

Thanks in advance.
Stefano

It is probably my two requests try to access to the same session object and cannot do it.

But this is what i wanna do!

Is there a workaround??

Thanks
Stefano


Solved it myself.

I created a application variable hashtable in wich i store SessionId and the id of the current logged in user.
In every web method i pass one new parameter that is SessionId.

Bye!
Stefano