Geeks With Blogs

News

Microsoft MVP


Moderator at CodeASP.NET


Quiz Master




free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

Using the MessageBox, ConfirmBox and FrameBox controls within Update Panel control is very easy. Just like other asp standard controls, you can just put the controls that you want to use within Update Panel and your good to go. Here's a simple demo I wrote just for your reference.

 

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProudMonkeyControlTEST.aspx.cs" Inherits="WebAppDemo.ProudMonkeyControlTEST" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register assembly="ProudMonkey.Common.Controls" namespace="ProudMonkey.Common.Controls" tagprefix="cc1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <cc1:MessageBox ID="MessageBox1" runat="server" />
            <cc1:ConfirmBox ID="ConfirmBox1" runat="server" />
            <cc1:FrameBox ID="FrameBox1" runat="server" />

            <asp:Button ID="Button1" runat="server" Text="ConfirmBox" OnClientClick="ShowConfirmBox(this,'Are you sure?');return false;" onclick="Button1_Click" /> 
            <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Show Message" />
            <asp:Button ID="Button3" runat="server" Text="Show my Blog" OnClientClick="ShowFrameBox('Vinz Blog','http://geekswithblogs.net/dotNETvinz/Default.aspx');return false;" />
        </ContentTemplate>
    </asp:UpdatePanel>
       
        
    </form>
</body>
</html>

 

CODE BEHIND:

using System;

namespace WebAppDemo
{
    public partial class ProudMonkeyControlTEST : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e){

        }

        protected void Button1_Click(object sender, EventArgs e) {
            MessageBox1.ShowInfo("You've just clicked Yes!");
        }

        protected void Button2_Click(object sender, EventArgs e){
            MessageBox1.ShowError("ERROR");
        }   
    }
}


That's it! I hope someone find this post useful!

Technorati Tags: ,
Posted on Thursday, January 5, 2012 10:47 PM | Back to top


Comments on this post: Using ProudMonkey Controls with ASP.NET AJAX Update Panel

# re: Using ProudMonkey Controls with ASP.NET AJAX Update Panel
Requesting Gravatar...
This is best one article so far I have read online. I would like to appreciate you for making it very simple and easy. I have found another nice post related to this post over the internet which also explained very well. For more details you may check it by visiting this url...........

http://mindstick.com/Articles/fa39a423-e004-4707-89c1-75936fc17676/?Panel%20Control%20in%20ASP.Net

Thanks
Left by Jeet Verma on Jan 10, 2012 11:13 PM

# re: Using ProudMonkey Controls with ASP.NET AJAX Update Panel
Requesting Gravatar...
Vinz, i have two issues. First, if i use onclick property with the messagebox control i got and exception!I changed for onclientclick and there works!
And the second one is that if i put the proudmonkey controls between the contenttemplate of the update panel, i lost the design view, so, i put it before the update panel and there apparently works, BUT, just the window appears with the ok button without the message.
Thanks again.
Left by Drakenaton on Jan 12, 2012 2:30 AM

# re: Using ProudMonkey Controls with ASP.NET AJAX Update Panel
Requesting Gravatar...
@Drakenaton,

I am able to reproduce issue #2 but I'm not sure exactky about issue #1. What do you mean by using onlick of the messageBox? if you want to use the MessageBox control in your javascript then you should use onclientclick event.
Left by Vinz on Jan 12, 2012 5:05 PM

# re: Using ProudMonkey Controls with ASP.NET AJAX Update Panel
Requesting Gravatar...
You see, I created a new ASP project on a trial with your own code. But when running, in addition to the changes that i told you about the UpdatePanel, I had to use the OnClientClick property instead of onclick because I get this exception when running: Button2_Click 'is not a member of' ASP.proudmonkeycontroltest_aspx.
Left by Drakenaton on Jan 12, 2012 8:23 PM

# re: Using ProudMonkey Controls with ASP.NET AJAX Update Panel
Requesting Gravatar...
@Drakenaton,

For issue #1. make sure that your ASPX page is pointing properly to your code behind file so that the event will be recognized.

For issue #2. You can set up the PostBack trigger of the UpdatePanel to resolve the issue. Check this post: http://geekswithblogs.net/dotNETvinz/archive/2012/01/12/using-messagebox-control-outside-updatepanel-control.aspx
Left by Vinz on Jan 12, 2012 8:28 PM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net | Join free