-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: atrehan
Message 2 in Discussion

Hi,   I tried to simulate your problem and was sucessfull to some level. Thats 
what we will discuss here. This poblem may be solved by Using events.   I had 
created a control named Control1.ascx and added 5 textboxes and 2 buttons "Add" 
and "Save" as you have said. In the user control code behind i.e. 
control1.ascx.vb i have few extra things   'First cretate and object of the 
page where u are using this control, lets say the page name is DataGridControl, 
so the class name will be 'same Dim objDataGrid as new DataGridControl   'Now 
we declare two events on this page for handling click of "Add" and "Save" 
button 'This is the event for handling click of Add button 'Here we have passed 
the values of all the textboxes on the User Control so that we can manipulate 
the data set by user Public event AddClicked(byval textbox1.text as string, 
byval textbox2.text as string, byval textbox3.text as string, byval 
textbox4.text as string,byval textbox5.text as string)    'This is the event 
for handling click of  Save button  'Here we have passed the values of all the 
textboxes on the User Control so that we can manipulate the data set by user  
Public event SaveClicked(byval textbox1.text as string, byval textbox2.text as 
string, byval textbox3.text as string, byval textbox4.text as string,byval 
textbox5.text as string)   'Now in the Page_Init subroutine of the user control 
we will attach these events to the functions that we want to call on the click 
of each button 'HandleAddClick is the subroutine that you will write on the 
aspx page for manipulating the data 'Also HandleSaveClick will be written on 
the same aspx page Addhandler AddClicked, Addressof  objDataGrid.HandleAddclick 
 Addhandler SaveClicked, Addressof  objDataGrid.HandleSaveclick     'Next thing 
is to Raise the events for Add and Save button 'When the user hits the Add 
button on the page, btnAdd_Click event of user control will be fired which in 
turn will fire the event AddClicked and as AddClicked is attached to 
HandleAddClick so at the end HandleAddClick on aspx page will be executed 
Private Sub btnAdd_Click(byval sender as object,byval e as system.eventargs) 
handles btnAdd.Click    RaiseEvent AddClicked('values of all the textboxes) Ens 
Sub   Similarly the save button will operate   But why you want to get these 
events on the aspx page when you can handle them in user control as well.   And 
the second problem of showing the data in the user control, for that you can 
write small piece of code in the page load of user control   If IsPostBack then 
   'Here Grid1:_ctl2:mControl1:TextBox1 is    'Grid1 is the id of the DataGrid  
  'ctl12 is autmaticaly generated by the GataGrid depending on the number of 
rows in the DatGrid    'TxtBox1 is the id of the text box on the user control   
 'Basically for getting this value you have to look in the view source of the 
page to know whats the name of the TextBox that Page uses    
TextBox1.Text=Request.Form("Grid1:_ctl12:myControl1:Textbox1")     'smilarly 
you can do for other TextBoxes end If     Plez provide your comments.   Thanks, 
Amit Trehan    

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to