Showing posts with label buttons. Show all posts
Showing posts with label buttons. Show all posts

Wednesday, March 28, 2012

link buttons in user control not recognised by updatePanel

Hello...

I have a usercontol that has some linkbuttons.....and an updatePanel...i put the linkbutton ID's in the Trigger section of the updatePanel, but I'm getting an error that the updatePanel does not recognise the button ID's I have passed in...

how do I fix this? thanks

Hi,

Update Panel is not gonna recognize those link buttons because they are inside of usercontrol. You need to create user control event for each link button event. For example,

CustomControl.ascx

<%@. Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="CustomControl" %>
<asp:LinkButton ID="lnkTest" runat="server" OnClick="lnkTest_Click">Test Button</asp:LinkButton

CustomControl.ascx.cs

public partial class CustomControl : System.Web.UI.UserControl
{
public delegate void TestHandler(object sender, EventArgs e);
public event TestHandler LinkClicked;

protected void Page_Load(object sender, EventArgs e)
{

}
protected void lnkTest_Click(object sender, EventArgs e)
{
if (LinkClicked != null)
LinkClicked(this, new EventArgs());
}
}

test.aspx

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CustomControl1" EventName="DoYourBussiness" />
</Triggers>
<ContentTemplate>
<uc1:CustomControl ID="CustomControl1" runat="server" OnLinkClicked="DoYourBussiness" />
</ContentTemplate>
</asp:UpdatePanel


Hi,

thanks for this, how about for normal hyperlinks?... (instead of linkButons)... can something similar be done?

thanks


Hi,

Normal hyperlinks do not have OnClick event. LinkButton looks the same as HyperLink, but has OnClick event.

Saturday, March 24, 2012

Literal Control Update Panel IE6

I have two buttons and a literal control placed inside an update panel which is sitting inside of a Drag Panel which is inside of some animation to display the initial panel. In IE7, everything works properly - when you click a button to refresh the image being drawn in the literal control, the button's text in changed to "Processing..." and then, when the response is obtained, the image is refreshed and the button's text is reverted back to its original state.

In IE7, however, the button works fine but the image never refreshs - even though I am re-writing the Literal upon postback. It is almost as if IE is caching the image. Does anybody know how to correct this issue?

Thanks!

In IE7 there is the animation disable by default, you can enable that in options.

Wednesday, March 21, 2012

Loading an Atlas enabled UserControl Dynamically. Urgent!

Hello,

I have 2 buttons within an UpdatePanel (for the menu) and another UpdatePanel (for the Content) where I load a control depending of the menu clicked.

MyControl1.ascx and MyControl2.ascx both content an UpdatePanel too.

Default.aspx:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>

<html>

<headid="Head1"runat="server">

<title></title>

<Atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

</head>

<body>

<formid="form1"runat="server">

<div>

<Atlas:updatepanelid="UpdatePanel1"runat="server"mode="Conditional"rendermode="Inline">

<contenttemplate>

<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>

<asp:ButtonID="Button2"runat="server"Text="Button"OnClick="Button2_Click"/>

</contenttemplate>

</Atlas:updatepanel>

<br/>

<Atlas:updatepanelid="UpdatePanel2"runat="server"mode="Conditional"rendermode="Inline">

<Triggers>

<Atlas:ControlEventTriggerControlID="Button1"EventName="Click"/>

<Atlas:ControlEventTriggerControlID="Button2"EventName="Click"/>

</Triggers>

<contenttemplate>

<asp:PlaceHolderID="PlaceHolder1"runat="server"></asp:PlaceHolder>

</contenttemplate>

</Atlas:updatepanel>

</div>

</form>

</body>

</html>

Default.aspx.cs:

using System;

using System.Text;

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;

publicpartialclass _Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedoverridevoid OnInit(EventArgs e)

{

base.OnInit(e);

if (Session["ContentControl"] !=null)

{

Control c = LoadControl(Session["ContentControl"].ToString());

PlaceHolder1.Controls.Add(c);

}

}

protectedvoid Button1_Click(object sender,EventArgs e)

{

Session["ContentControl"] ="/MyContent1.ascx";

}

protectedvoid Button2_Click(object sender,EventArgs e)

{

Session["ContentControl"] ="/MyContent2.ascx";

}

}

MyContent1.ascx:

<%@dotnet.itags.org.ControlLanguage="C#"AutoEventWireup="true"CodeFile="MyContent1.ascx.cs"Inherits="MyContent1"%>

<IGI:updatepanelid="Updatepanel1"runat="server"mode="Conditional"rendermode="Inline">

<contenttemplate>

MyContent1

</contenttemplate>

</IGI:updatepanel>

MyContent2.ascx:

<%@dotnet.itags.org.ControlLanguage="C#"AutoEventWireup="true"CodeFile="MyContent2.ascx.cs"Inherits="MyContent2"%>

<IGI:updatepanelid="Updatepanel1"runat="server"mode="Conditional"rendermode="Inline">

<contenttemplate>

MyContent2

</contenttemplate>

</IGI:updatepanel>

My problem is I have to click twice on a button for the Content control to load because the OnInit is executed before theButton1_Click.( the session is not updated yet when the OnInit is executed );

Anybody has an idea to achived this in One Click??

Many Thanks,

Yann

Did anyone every respond to you on this question? I am having the same problem, and I could only solve it (kind of) by using a master page.

I wrapped the ContentPlaceHolder in the master page inside an UpdatePanel, and in my actual page, I put another PlaceHolder for holding my dynamically created user control (or other type of control based on my portal's configuration).

I would like to know if anyone ever answers this, and I would also like to be able to use WebParts in this scenario, which I have NEVER gotten to work with Atlas and dynamic user controls reliably.