Showing posts with label visible. Show all posts
Showing posts with label visible. Show all posts

Monday, March 26, 2012

DetailView and UpdatePanel

Hi,

I'm having an error trying to put a GridView visible from a Ok button placed in a DetailView control template and an updatepanel. It says that I can not add an invalid control Id to the trigger.

Can somebody help me on that?

Idea

hello-

how are you getting the id of the button? i think that you might not be getting a reference to the button...


Of course it is, the problem is that the control is inside a grid view template, so I want to see how I can reference that control in a way that the updatepanel can see it.

Here is my code

<atlas:UpdatePanelID="UpdateGridUsers"runat="server">

<triggers><atlas:controleventtriggercontrolid="ButtonCancel"eventname="ItemCommand"/></triggers>

I have the code placed for the trigger. The button name is Button cancel, but it is inside of a template in the DetailView like this

<InsertItemTemplate><asp:ButtonID="ButtonInsert"runat="server"CausesValidation="True"CommandName="Insert"Text="Insert"/> <asp:ButtonID="ButtonCancel"runat="server"CausesValidation="False"CommandName="Cancel"Text="Cancel"/></InsertItemTemplate>

Wednesday, March 21, 2012

Declarative xml-script from UpdatePanel

Is there a way to insert (and execute) declarative xml-script from UpdatePanel?

For example following code works if control is visible, so xml-script is loaded with the page. If control is hidden, or created at run time xml-script is not executed.

test.aspx:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" %>
<%@dotnet.itags.org. Register TagPrefix="uc" TagName="Control1" src="http://pics.10026.com/?src=~/WebUserControl.ascx" %>
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
c1.Visible = true;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>Untitled Page</title></head>
<body>
<form id="form1" runat="server">

<atlas:ScriptManager ID="ScriptManager" runat="server" EnablePartialRendering="true" />

<atlas:UpdatePanel ID="p1" runat="server" Mode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<uc:Control1 ID="c1" runat="server" Visible="false" />
</ContentTemplate>
</atlas:UpdatePanel>

</form>
</body>
</html>

WebUserControl.ascx:

<%@dotnet.itags.org. Control Language="C#" ClassName="WebUserControl" %>

<div id="panel">Click the button to Hide me</div>
<input id="hideButton" type="button" value="Hide" />

<script type="text/xml-script">
<page xmlns="http://schemas.microsoft.com/xml-script/2005">
<components>
<control id="panel" />
<button id="hideButton">
<click>
<setProperty target="panel" property="visible" value="false" />
</click>
</button>
</components>
</page>
</script>

hello.

well, where's your panel control? if it's inside a user control, then you've already found your problem: the user control is a naming container class. this means that controls declared inside it will have a different client side id (it will be composed by the usercontrol id and the control id).


I thought client side id only changed for webform controls. This panel is just a plain <div>.

And if I just make user control visible from the start, it works, xml-script executes.


hello.

yes, if it's an html control, then you're right. not sure about the visibility...can you show me the div declaration that you have in the user control?


The div declaration is actually in the code above:<div id="panel">Click the button to Hide me</div>

I choose to hide div just for sample sake, it can be any xml-script.

Anyway, I recall now, javascript doesn't execute either, when it's inside control template and then the control instantiated inside update panel. The only way is to use RegisterXYZScript(...). But RegisterXYZScript(...) doesn't work for xml-script.

When using ScriptManager RegisterControl it places xml-script inside of that <xmlScript> tag at the end of update panel's <delta> response. I think it executes it, but there beside RegisterControl I didn't find any more methods to generate xml-script.

I know there is a way to write an ExtenderControl, and use ScriptTextWriter to generate xml-script. I haven't tried that yet.