Custom Web Button

Oct 8 2008 7:08 AM
I've been searching the web for 2 days already for something that could help with my problem, I'm currently developing a custom web button, the requirement for it is to be able to have a image has background, text and a embended image...I've been doing the code for it and it's current state is like this:

#Render web control page
protected override void Render(HtmlTextWriter output) 
         {
             HtmlButton button = new HtmlButton();            
             button.Style.Add("text-align","center");
             button.Style.Add("vertical-align", "middle !important");
             button.Attributes.Add("runat", "server");
             button.InnerHtml = "<table><tr><td><img src='"+this.src+"' alt='Embedded image' /></td><td>"+this.Text+"</td></tr></table>";
             button.Attributes.Add("onclick","DoPostBack(this.id,'')");
             button.Attributes.Add("onserverclick", "teste_OnClick");
             button.RenderControl(output);
         }


#javascript on the default page
    function DoPostBack(element)
    {
        __doPostBack(element,"");
    }


#codebehind default page
        void teste_OnClick(object Source, EventArgs e)
        {
            Span1.InnerHtml = "You clicked Button1";
        }


The current issue is that when I click the button, it does the postback but it doesn't fire the method in the codebehind.

Any help with this would be great, since I just hit a huge brick wall with this one.

Thanks
Claudio Correia

Answers (1)