Answered by:
Command of dynamic controls

Question
-
User1571226316 posted
Hello,
I would like to create a button dynamicaly and assign an onclick event. This event is a redirection.
this is my code :
Button btn = new Button(); btn.Text = "Go !"; btn.CommandArgument = reader.GetOracleValue(0).ToString(); btn.CausesValidation = false; btn.Command += new CommandEventHandler(btnDynamique_Command); tCellbt.Controls.Add(btn); TableCell tCellbt = new TableCell(); tr.Cells.Add(tCellbt);
I also tried with the parameter "PostBackURL" but I use SharePoint and there is a problem with it.
The code works with an other page, that's why I don't understand..
If you have any ideas..
Regards
Monday, June 23, 2008 7:40 AM
Answers
-
User-1187166364 posted
Button dynamButton = new Button();dynamButton.Id =
"DynamButton"; void dynamButton_Click(object sender, EventArgs e){
throw new NotImplementedException();}
This is the way i use and it's quite a standard. But it seems you are trying to use this in some sort of data binding. can you please reveal more what your are trying to do ..
As i have only used CommandArgument in the gridview or data grid. and where have you set the commandName
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 23, 2008 10:03 AM -
User481221548 posted
Hello tomar99
Assign a ID to your Button and write the code - in the best case - to Page_OnInit.
That should works.What kind of issue coming up with Sharepoint and PostBackUrl?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, June 25, 2008 3:31 AM -
User1571226316 posted
It works.
It wasn't call during the page_load..
When I use PostBackUrl with SharePoint, it redirects me on the good url but I have to refresh the page (when I click, SharePoint says "the page change, you need to refresh the page....", I click on the link and after, I'm on the good page). Every time I have this message. That's why i need to use an other solution. And with buttons, it works !
Thanx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, June 25, 2008 5:01 AM
All replies
-
User-1187166364 posted
Button dynamButton = new Button();dynamButton.Id =
"DynamButton"; void dynamButton_Click(object sender, EventArgs e){
throw new NotImplementedException();}
This is the way i use and it's quite a standard. But it seems you are trying to use this in some sort of data binding. can you please reveal more what your are trying to do ..
As i have only used CommandArgument in the gridview or data grid. and where have you set the commandName
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 23, 2008 10:03 AM -
User481221548 posted
Hello tomar99
Assign a ID to your Button and write the code - in the best case - to Page_OnInit.
That should works.What kind of issue coming up with Sharepoint and PostBackUrl?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, June 25, 2008 3:31 AM -
User1571226316 posted
It works.
It wasn't call during the page_load..
When I use PostBackUrl with SharePoint, it redirects me on the good url but I have to refresh the page (when I click, SharePoint says "the page change, you need to refresh the page....", I click on the link and after, I'm on the good page). Every time I have this message. That's why i need to use an other solution. And with buttons, it works !
Thanx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, June 25, 2008 5:01 AM -
User481221548 posted
Hello tomar99
PostBackUrl makes a PostBack to another site, that means, the site is chancing.
That means fourther, you have to do a full rountrip / refresh.Thats the theory, AFAIK.
Wednesday, June 25, 2008 6:55 AM