Create Custom Web Part Properties in ShatrPoint

Step 1: Open form solution in Visual Studio.

Step 2: Add new item to the empty share point project.I.e is visual web part.

Step 3: Based of our need we have to design like below process.

design

Step 4: 
  1. public VisualWebPart() {}  
  2. string strbank = "India";  
  3. [WebBrowsable(true), WebDisplayName("BankName"), WebDescription("setBankName"), Personalizable(PersonalizationScope.Shared)]  
  4. public string proBank {  
  5.     get {  
  6.         return strbank;  
  7.     }  
  8.     set {  
  9.         strbank = value;  
  10.     }  
  11. }  
  12. //Bank Location  
  13. //collection of object like dropdown  
  14. public enum enumBankLocations {  
  15.     noida, hyderabad, chennai, newdelhi  
  16. }  
  17. enumBankLocations enumLocation;  
  18. [WebBrowsable(true), WebDisplayName("Bank Location"), WebDescription("Select Bank Location"), Personalizable(PersonalizationScope.Shared)]  
  19. public enumBankLocations proBankLocation {  
  20.     get {  
  21.         return enumLocation;  
  22.     }  
  23.     set {  
  24.         enumLocation = value;  
  25.     }  
  26. }  
  27. //status  
  28. bool boolAccount = true;  
  29. [WebBrowsable(true), WebDisplayName("Account Status"), WebDescription("Set Account Statuss"), Personalizable(PersonalizationScope.Shared)]  
  30. public Boolean proAccStatment {  
  31.     get {  
  32.         return boolAccount;  
  33.     }  
  34.     set {  
  35.         boolAccount = value;  
  36.     }  
  37. }  
Step 5: Then go to our button functionality.
  1. protected void Button1_Click(object sender, EventArgs e) {  
  2.     string strstatus = "";  
  3.     if (proAccStatment == true) {  
  4.         strstatus = "AccountCreated";  
  5.     } else {  
  6.         strstatus = "Not Created";  
  7.     }  
  8.     Label1.Text = "<br>EmpName:" + TextBox1.Text + "<br>BankName:" + proBank + "<br>BankLocation" + proBankLocation + "<br>AccountStatus" + strstatus;  
  9. }  
Step 6: After Deployment success.Open Our Share point Site And Insert our custom web part.

Step 7:
Edit the web part properties in right side panel like this.
 
 
Step 8: Then This Is Our Custom Web Part Properties. 

Finally, create Custom Web Part Properties to our visual web part. 
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now