Retrieve PostBack value of dynamic control

N

Nick

Hi all
I am hoping that someone would respond to what I am calling a puzzle: obtain the postback value of dynamic hidden control
I am posting a short version of the code, thx for your help

public class AccountSummaryInfo : System.Web.UI.WebControls.WebControl, IPostBackDataHandle
{
#region Constructor/Deconstructo
public AccountSummaryInfo(string StrAccountNum
{
InitializeDataGrid()
BuildControls()
}//End constructo
#endregio

private void BuildControls(
{

protected virtual void Click(object sender, System.EventArgs e)
{
Button btn = (Button)sender
if (btn.CommandName.Equals("Previous")
{ //Code her
_strKey = “Some Valueâ€
Page.Server.Transfer(cPAGENAME,true)

else if (btn.CommandName.Equals("Next")

//Code her
_strKey = “Some Other Valueâ€
Page.Server.Transfer(cPAGENAME,true)

}//End Clic

private void InitializeDataGrid()

}//End DefineDataGrid(
private void GetData(string _strCommand
{
_strKey = “value Aâ€
_strPreviousKey = “value 1â€
}//End GetData(
private void CreateGrid(string[] aList
{
}//End CreateGrid()

protected override void OnPreRender(EventArgs e)

Controls.Add(new LiteralControl("<input type='hidden' name='Key' value='" + _strKey + "'>"))
Controls.Add(new LiteralControl("<input type='hidden' name='PreviousKey' value='" + _strPreviousKey + "'>"))
base.OnPreRender(e)
}//End OnPreRender(
protected override void OnInit(EventArgs e)

GetData(strCommand)
UpdateGrid();
base.OnInit(e)
}//End OnInit(
private void UpdateGrid(


}//End clas
}//end namespac
 
R

Robert Koritnik

First of all: CommandName & CommandArgument are posted via Command event,
not Click and because U use those it's best to fire Command event instead of
Click.
Second: Where do you implement IPostBackDataHandler methods?

The best way is to check a sample in MSDN and create your control like it
should be.

If your class implements some interface it doesn't mean that all things get
done automaticly. It only means that you should implement the methods and do
the work by yourself. It just helps you to make correct methods.

So you must implement LoadPostData and if you need to also
RaisePostDataChangedEvent which executes event delegates that MAY be defined
on the page that displays your Custom control.

--
RobertK
{ Clever? No just smart. }

Nick said:
Hi all,
I am hoping that someone would respond to what I am calling a puzzle:
obtain the postback value of dynamic hidden control.
I am posting a short version of the code, thx for your help.

public class AccountSummaryInfo : System.Web.UI.WebControls.WebControl, IPostBackDataHandler
{
#region Constructor/Deconstructor
public AccountSummaryInfo(string StrAccountNum)
{
InitializeDataGrid();
BuildControls();
}//End constructor
#endregion

private void BuildControls()
{
}
protected virtual void Click(object sender, System.EventArgs e)
{
Button btn = (Button)sender;
if (btn.CommandName.Equals("Previous"))
{ //Code here
_strKey = "Some Value";
Page.Server.Transfer(cPAGENAME,true);
}
else if (btn.CommandName.Equals("Next"))
{
//Code here
_strKey = "Some Other Value";
Page.Server.Transfer(cPAGENAME,true);
}
}//End Click

private void InitializeDataGrid()
{
}//End DefineDataGrid()
private void GetData(string _strCommand)
{
_strKey = "value A"
_strPreviousKey = "value 1"
}//End GetData()
private void CreateGrid(string[] aList)
{
}//End CreateGrid()

protected override void OnPreRender(EventArgs e)
{
Controls.Add(new LiteralControl("<input type='hidden' name='Key' value='" + _strKey + "'>"));
Controls.Add(new LiteralControl("<input type='hidden' name='PreviousKey'
value='" + _strPreviousKey + "'>"));
 
N

Nick

Actually I stripped out the code for IPostBackDataHandler, but it is there
Should'nt the postback event gets fired and post the values as in Framework 1.0
Nick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top