Monday, March 26, 2012

updatepanel & declar. way of behavior (after refresh)

Hi guys,

please can somebody help me with this issue, I probably missed something important (and small?;-))...but what could it be?

I have problem with UpdatePanel & behavior defined by declarative way. I sent you little source code which demonstrates problem. There are 2 labels and 1 button on updatepanel. After loading page when I click first label, second label should hide (there is come error now, but minority for me...although if somebody explains me why, it would be great)...ok event is caught and something happened (I agree, nothing nice now :-))...but main problem is comming, if I first press button (which makes postback and update text of Label1) and after I click Label1 - ooups nothing happened, click behaviour of Label1 disappeared. If you have any ideas, pls divide it.

Thx and have a nice day

MilKob

<%

@dotnet.itags.org.PageLanguage="VB" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<scriptrunat="server">

ProtectedSub Button1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

Label1.Text = Now.ToString

EndSub

</

script>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"></atlas:ScriptManager><div><atlas:UpdatePanelrunat="server"ID="updpanel"Mode="Always">
<ContentTemplate>
<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/><asp:LabelID="Label2"runat="server"Text="Label"></asp:Label></ContentTemplate></atlas:UpdatePanel></div>

<scripttype="text/xml-script">

<page xmlns:script=

"http://schemas.microsoft.com/xml-script/2005">

<components>

<control id=

"Label1" >

<behaviors>

<clickBehavior>

<click>

<setProperty target=

"Label2" property="visible" value="false" />

</click>

</clickBehavior>

</behaviors>

</control>

</components>

</page>

</script></form>

</

body>

</

html>hello.

i think that the problem is that the xml script that is sent from the server after the button click is "empty" and due to that you loose the behavior you've added on the initial page.

so, i'd suggest that you'd do what you're after with javascript.

Hi Luis,

thank you for your answer, although I little hoped there is a way which doesnt avoid declarativelly approach (I like it (maybe too much:-))), there is probably necessary to do that in javascript (which I wanted avoid...)

Thx again

Milo

No comments:

Post a Comment