Current location: Hot Scripts Forums » Programming Languages » ASP.NET » Creating buttons on the fly - asp.net - postback not working


Creating buttons on the fly - asp.net - postback not working

Reply
  #1 (permalink)  
Old 09-27-06, 06:09 PM
csm csm is offline
New Member
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Creating buttons on the fly - asp.net - postback not working

Can someone tell me why when i run the following code - it creates a button - and when i click on it - instead of creating a new button based on logic - it clears the screen.

Code:
 
<script runat="server">
Protected WithEvents frmButton As System.Web.UI.WebControls.Button
 
Private Sub Page_sub(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
if not ispostback then
setupButtons(44)
end if
end sub
 
private sub setupButtons(byval dbl as double)
frmButton = New Button()
frmButton.ID = "btnSkip" & dbl
AddHandler frmButton.Click, AddressOf SkipSection
frmButton.Text = "button " & dbl
Form1.Controls.Add(frmButton)
Form1.controls.add(New LiteralControl("
"))
end sub
 
Sub SkipSection(ByVal sender As System.Object, ByVal e As System.EventArgs)
setupButtons(34)
end sub
</script>
<form runat="server" id="form1">
 
</form>

Last edited by digioz; 10-07-06 at 10:39 PM. Reason: Please use CODE tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-12-06, 08:14 AM
Naresh Rohra Naresh Rohra is offline
Newbie Coder
 
Join Date: Jun 2004
Location: India
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
The thumb rule is that never code any ui things in Page.Init event, use Page.Load event instead. Page.Init is best used for initialising class members only.
regards,
Naresh.
__________________
My Home Page
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Back buttons (working multiple times, not like referer) zitwep JavaScript 1 07-14-06 05:33 AM
Creating an image gallery on the fly BMS Script Requests 4 04-06-06 04:43 PM
hey there, im creating links that arnt working any help? 0o0o0 PHP 4 10-03-05 07:37 PM
Creating Nested Repeaters with ODBC .net and ASP.net GO4TF4CE ASP.NET 0 08-13-04 05:33 AM
help for creating dynamic checkbox in asp.net l3nny ASP.NET 1 07-01-04 07:45 AM


All times are GMT -5. The time now is 10:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.