Showing posts with label click. Show all posts
Showing posts with label click. Show all posts

Wednesday, March 28, 2012

Extender not collapsing when button clicked - code posted. Using Fridays build 11/10

When I click on the button - the extender should collapse. It collapses when I click on the header of pnlHeader. But not when I click on the button.
This code worked in beta 1. If I get rid of the updatepanel it works.

<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<atlas:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" RenderMode="inline">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<ajaxToolkit:CollapsiblePanelExtender ID="cpe" runat="Server" TargetControlID="pnlAddAccounts"
ExpandControlID="pnlHeader" CollapseControlID="pnlHeader" Collapsed="False" ImageControlID="Image2"
SuppressPostBack="true">
</ajaxToolkit:CollapsiblePanelExtender>
<asp:Panel ID="pnlHeader" runat="server" Visible=true style="cursor: pointer;" CssClass="collapsePanelHeader">
<table border=0 cellpadding=3 cellspacing=0 width="100%" height="20px">
<tr><td align=center valign=middle width="97%">Additional Accounts</td>
</tr></table>
</asp:Panel>

<asp:Panel ID="pnlAddAccounts" runat="server" Visible="true" style="overflow:hidden;">
asdfaslkdjflajsfdlj
</asp:Panel>
</ContentTemplate>
</atlas:UpdatePanel>
</div
</form>

protected void Button1_Click(object sender, EventArgs e)
{
cpe.Collapsed = true;
cpe.ClientState = "true";
}

I've just createdwork item 5688, "Switch to ScriptManager.RegisterHiddenField for ClientState backing store", to track this problem. Here's the description from the work item:

The investigation ofhttp://forums.asp.net/thread/1462069.aspx led to the realization that an ASP.NET AJAX behavior change between Beta1 and Beta2 such that Extender controls now have their GetScriptDescriptors methods called during Render (instead of PreRender) can cause breaking changes for users who update ClientState during async postbacks. Specifically, the updated ClientState value won't necessarilly be included in the updated UpdatePanel content that's sent back to the browser. The fix for this is to use ScriptManager.RegisterHiddenField to create the relevant backing store. It's supposed to be fairly straightforward to do.

Sorry for the trouble, we'll get this fixed for our next release!


I don't have this property ScriptManager.RegisterHiddenField in my scriptmanager...

When the next release is supposed to go out?

Thanks


With luck, sometime soon-ish. :)

Saturday, March 24, 2012

Exception has been thrown by the target of an invocation

I have a scriptmanager and updatepanel, inside the panel is a gridview it's bound to an objectdatasource, when I click the select button in the grid I get the alert with the message "Exception has been thrown by the target invocation". How would I know the source of this error, or what is causing the error. Is there a way to get the real exception that occurred not just a message?

Thanks

Disable the ajax for a moment (EnablePartialRendering="false" on the scriptmanager).
This error message is about as useful as a chocolate fireguard. Disabling the update panel is fine for development, and the few bugs that I stumble across while developing. But what about in a production situation. If I get my clients phoning up telling me the app won't work becuase an "Exception has been thrown by the target of an invocation", then I'll just explain to them how to disable AJAX so I can get a useful error message. AHH. No. I don't think so. Is there some way that you can actually pass the message text up to the popup box. Dev's like me are pretty reliant on the exception text. Especially as we often just write stuff and then it gets put into production without rigourous testing. Not ideal, but thats what happens in the real world outside of Redmond.

Was this resolved at all? I have a similar issue:

Steps to Reproduce

1) I have a DB table with a column which is varchar(1024)

2) I want this column to only contain unique strings

3) So I add a trigger to the column to check for the data entered and use RaisError if any problems

4) I setup my Datagrid/ObjectDataSource/BLL/DAL and all works fine in aspx, the page errors with the correct message.

5) I add in an AJAX Update Panel and *it* (the ASP.NET AJAX Libraries) just spits out a JSON string containing an alert message "An exception occured by the the target of an invocation". THAT is not the correct error string.

Why is it not? and how do I alter this behaviour to make it send a JSON string containing the correct Error message?

Thank


Was this resolved at all? I have a similar issue:

Steps to Reproduce

1) I have a DB table with a column which is varchar(1024)

2) I want this column to only contain unique strings

3) So I add a trigger to the column to check for the data entered and use RaisError if any problems

4) I setup my Datagrid/ObjectDataSource/BLL/DAL and all works fine in aspx, the page errors with the correct message.

5) I add in an AJAX Update Panel and *it* (the ASP.NET AJAX Libraries) just spits out a JSON string containing an alert message "An exception occured by the the target of an invocation". THAT is not the correct error string.

Why is it not? and how do I alter this behaviour to make it send a JSON string containing the correct Error message?

Thank you

example "Using the ASP.Net "Atlas" XmlDataSource control" doesnt work!

on :http://atlas.asp.net/docs/atlas/doc/data/default.aspx#XmlDataSource, the "Using the ASP.Net "Atlas" XmlDataSource control" doesn't work.
On click of the link, I redirect it to the http://www.asp.net/forums page.

Can someone help me solving the problem?

Thanks in advace,
Stefano

Stefano,

This appears to work for me. Can you please try it again in a new browser window? Alternatively, you can go tohttp://atlas.asp.net/docs/atlas/doc/data/default.aspxand then scroll down.

Thanks,

Shanku


Sorry, I did not mean to say that the link does not work, but that the example does not work.
If I click "Run it" button in the examples it opens the page: http://atlas.asp.net/docs/atlas/samples/data/XmlDataSource.aspx.
If I click the "Sample Post" link, I redirect to the http://www.asp.net/forums page.

EventValidation error msg!

one of the Atlas control popup me something that i need to implement an event agrument or something!! ?? tha happen on a click of a ListBox control.

i am verry confuse here !

"Invalide postback or callback argument. Event validation is enabled using <page enableEventValidation=true> in configuration or in the page. For security purposes, this features verifies taht arguments to postback or callback events origiante from the server control that originally rendered them. If the data is valid and expected, use the ClickScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."

What im suppose to do with that now?

I fix it !!

this is what i did.. i had a UpadatePanel inside a UpdatePanel.. and thats what was causing a script Popup msg !!

Wednesday, March 21, 2012

events calendar with PopupControlExtender

I developed an events calendar in .NET 2.0. When you click on a calendar date, the details for that day are retrieved from a database and displayed in a repeater. I'd like to use the PopupControlExtender to display the details in a popup panel instead. How can I go about assigning the TargetControlID of the PopupControlExtender to work with the Calendar. Thanks in advance for any suggestions.

Jay

Hi Jay,

Based on my experience, the easies way is set PopupControlExtender's TargetControlID to a hidden control. We first Attach a Javascipt function to CalendarExtendar's onselect(add_dateSelectionChanged) event.The Javascript will show the PopupControlExtender and adjust its showing position.

To attach a Javascript to Calendar, we assume that the Calendar is a CalendarExtender.(Since the Calendar is written by you, so you should have easier way).

function pageLoad() { $find("CalendarExtender's BehaviorID").add_dateSelectionChanged("your function name here");}

To adjust the panel's postion, we should use $common.setLocation($get("<%=Popped up Panel's ClientID%>"),new Sys.UI.Point(x , y));

Hope this help.

Best regards,

Jonathan.

Events are not triggered ?

Hello

How does it come that when I use the click event of an asp:Button control to trigger an asynchronous roundtrip to the server, it works.
When I use the TextChanged event of the asp:TextBox control however, nothing happens...

Here is my example code:

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:UpdatePanel ID="myUpdatePanel" runat="server">

<ContentTemplate>

<asp:Label ID="myLabel" runat="server" Text=""></asp:Label>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="myTextBox" EventName="TextChanged" />

</Triggers>

</asp:UpdatePanel>

<div>

<asp:TextBox runat="server" ID="myTextBox" Text=""></asp:TextBox>

<asp:TextBox runat="server" ID="SecondTextBox" Text="Second"></asp:TextBox>

</div>

<

asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>

<asp:UpdatePanelID="myUpdatePanel"runat="server">
<ContentTemplate>
<asp:LabelID="myLabel"runat="server"Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTriggerControlID="myTextBox"EventName="TextChanged"/>
</Triggers>
</asp:UpdatePanel><div>
<asp:TextBoxrunat="server"ID="myTextBox"Text=""></asp:TextBox>
<asp:TextBoxrunat="server"ID="SecondTextBox"Text="Second"></asp:TextBox>
</div>I think you'll find it probably needs to trigger a postback to work. Try using AutoPostBack="true" on the textbox in question.

Check out this great post by Luis:

http://forums.asp.net/thread/1532495.aspx

Cheers,

Bogdan


The solution to my problem is as follows

<script type="text/javascript">

$addHandler($get("txtName"), "keyup", functionToExecute);

function functionToExecute(e)
{

}

</script>

Escape Key Behaviour

Hey,

One of my users just discovered the following:

If you hit ESC twice when on a page containing an update panel with a control inside, if you click on anything else that does a postback, you'll get aSystem.ArgumentException: Invalid postback or callback argument. Event validation is enabled using [...] error.

I would like to know more about the default behaviour of the ESC key. And might be interested in hooking up to the event to fire something else when that happens.

Note: I am still using the July CTP (haven't had time / fond it necessary to upgrade yet, so maybe this issue no longer exists now).

Thanks,

Jason

Okay just upgraded to 1.0 RTM and I'm no longer gettingpostback or callback argument exceptions. However, if I do it during a postback, I do see that my updateprogress stays open. In my old one, it didn't seem to have any effect.

Are there any references to the escape key behaviour?

Jason