ygermain

pretty new at .net/c#...so sorry for asking this if it does not make sense, but would really appreciate some hint/explanation

in my c# code, i use writer.write(...) to generate most of my html, for one of the html button, i would like to call a c# method onclick, can i do this or is it purely not possible b/c of having this html running on the client side and not having access to that C# method

here is the code that iam trying to implement:

using System;
../..

private void LoadDashBoard(HtmlTextWriter writer)

{
.../...

writer.WriteBeginTag("button");
writer.WriteAttribute("id", "nbuserdetail");
writer.Write("<ASP:BUTTON TEXT=\"Details\" ID=\"doAdd\" OnClick=\"btnUserStatDetails_Click();\" RUNAT=\"server\"/>");
writer.WriteEndTag("button");

.../...

}

btnUserStatDetails_Click()

{.../...}



Re: .NET Base Class Library call my C# method from within writer.write()?

Adam Wayne

It wouldn't work quite like that; you won't be able to write control code directly to the writer. However, you should be able to use the GetPostBackEventReference method (http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx) to get a javascript call that will cause a post back passing some arguments that you provide it.

Hope this helps!