| Author: R.M.Phani Kumar 02 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
Hi Geetha Its Pretty simple...just follow the below steps
1.create a VS-2003/05/08 web application with a sample name 2.add a userControl with sample name like frmSave.ascx 3.Add the controls like you mentioned (4 text boxes and 1 save button) 4.In the click event of the button write the corresponding logic as in dotnet development.
Once the above steps are completed
5. now add the user control to the web part as shown below in CreateChildControls method.
Code part UserControl ucSampleWP = null; protected override void CreateChildControls() { try { this.ucSampleWP = (UserControl)Page.LoadControl(@"/styles/Controls/frmSave.ascx"); this.Controls.Add(this.ucSampleWP ); } catch { throw; } } 6. Now compile you webpart and safe control entry in web.config
Copy the ascx file and codebehind file to \\YourServiverName\siteName\Styles\Controls folder.
add the webpart in desired page and see the result
Please revert further if u r facing any issue
Happy coding
Regards Phani Kumar R M
|
| Author: Pradeep Kumar 13 Nov 2009 | Member Level: Gold | Rating:  Points: 2 |
There are two ways of doing this.
1) You can hardcode connection string in you web part code and use SqlConnection and SqlCommand object to do database operation like you normally do in asp.net application.
2) Define connection string in sharepoint application web.config file like you normally do in asp.net application web.config and red it using below code. Configuration config = WebConfigurationManager.OpenWebConfiguration("/", this.WebApplication.Name); string _sqlConnectionString = config.ConnectionStrings.ConnectionStrings["DBConnectionString"].ToString();
The second was is preferable, because you can configure connection string which can be modified any time.
|