I am creating my fi开发者_运维百科rst custom web part (visual web part) for SharePoint server 2010.
I added some controls (text boxes) by drag 'n drop and I use them on a form to create new sites.
I thought I could use the usual
string siteName = txtSiteName.ToString();
string siteDescription = txtSiteDescription.ToString();
And then (just a small part of the code)
newWeb = SPContext.GetContext(HttpContext.Current).Web.Webs.Add(
siteUrl, siteName, siteDescription, (uint)1033, "STS#1", true, false);
It works when I create a site for the first time but the second time I get
<nativehr>0x800700b7</nativehr><nativestack></nativestack>
The Web site address "/mySite/System.Web.UI.WebControls.TextBox" is already in use.
How am I suppose to use web form controls when I create a web part?
Thanks in advance.
I realized I have to use .Text instead of .ToString()
string siteName = txtSiteName.Text;
string siteDescription = txtSiteDescription.Text;
精彩评论