(With Static Data and Dynamic Data Source)
Ø
To create a custom webpart properties in
SharePoint we should follow one stranded approach.
Ø
Basically we can create following custom
properties with only inheriting of webpart
class
1.
check box
2.
dropdown
3.
textbox
Ø
To create any above controls we should write the
following property attributes of visual
webparts
[Category("Extended Settings"), //we can provide any name as category
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Sample Drop Down"), //here we have to provide control display name(opnl)
WebDescription("Please
Choose a Sample DropDown")] //optional
·
Category – This will group your property according to category. If
not declared, “Miscellaneous” will be used as the default.
·
Personalizable – How the WebPart is configured, which can be per-user (PersonalizationScope.User), or for
everyone (PersonalizationScope.Shared). For this example, we have chosen all users.
·
WebBrowsable – This will hide or show the property on the tool pane.
·
WebDisplayName – Label for the property.
·
WebDescription – Description for the property.
Ø
In webPart properties by
declaring of property, the controls will be initialized.
Ø
the deferent types of property
types and equivalent control initializations on pane as follows.
The above property types are provide limited controls
but if you want to create more or any user control and provide initialization
values dynamically, we have to inherit and implement few abstract classes and
interfaces. we can discuss about them after these controls creation.
v BOOL (Check
Box):
public Boolean _property; //
this line creates check box
[System.Web.UI.WebControls.WebParts.WebBrowsable(true),
System.Web.UI.WebControls.WebParts.WebDisplayName("Check box property"),
System.Web.UI.WebControls.WebParts.WebDescription(""),
System.Web.UI.WebControls.WebParts.Personalizable(
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
System.ComponentModel.Category("Gowtham Custom Properties"),
System.ComponentModel.DefaultValue("")]
[System.Web.UI.WebControls.WebParts.WebBrowsable(true),
System.Web.UI.WebControls.WebParts.WebDisplayName("Check box property"),
System.Web.UI.WebControls.WebParts.WebDescription(""),
System.Web.UI.WebControls.WebParts.Personalizable(
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
System.ComponentModel.Category("Gowtham Custom Properties"),
System.ComponentModel.DefaultValue("")]
public Boolean _Property // the check
box value available here.
{
get { return _property; }
set { _property = value; }
}
{
get { return _property; }
set { _property = value; }
}
v
Enum
(Dropdown):
public enum Dropdownvalues { List1, List2, List3 };
protected Dropdownvalues selected_value ;
[System.Web.UI.WebControls.WebParts.WebBrowsable(true),
System.Web.UI.WebControls.WebParts.WebDisplayName("Select the List"),
System.Web.UI.WebControls.WebParts.WebDescription(""),
System.Web.UI.WebControls.WebParts.Personalizable(
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
System.ComponentModel.Category("Gowtham Custom Properties"),
System.ComponentModel.DefaultValue("")]
protected Dropdownvalues selected_value ;
[System.Web.UI.WebControls.WebParts.WebBrowsable(true),
System.Web.UI.WebControls.WebParts.WebDisplayName("Select the List"),
System.Web.UI.WebControls.WebParts.WebDescription(""),
System.Web.UI.WebControls.WebParts.Personalizable(
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
System.ComponentModel.Category("Gowtham Custom Properties"),
System.ComponentModel.DefaultValue("")]
public Dropdownvalues selected_value //
selected value available here
{
get { return _list; }
set { _list = value; }
}
{
get { return _list; }
set { _list = value; }
}
v
TextBox (String, int,Date):
public static string/int/Date _value;
[System.Web.UI.WebControls.WebParts.WebBrowsable(true),
System.Web.UI.WebControls.WebParts.WebDisplayName("Enter the Value"),
System.Web.UI.WebControls.WebParts.WebDescription(""),
System.Web.UI.WebControls.WebParts.Personalizable(
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
System.ComponentModel.Category("Gowtham Custom Properties"),
System.ComponentModel.DefaultValue("")]
[System.Web.UI.WebControls.WebParts.WebBrowsable(true),
System.Web.UI.WebControls.WebParts.WebDisplayName("Enter the Value"),
System.Web.UI.WebControls.WebParts.WebDescription(""),
System.Web.UI.WebControls.WebParts.Personalizable(
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
System.ComponentModel.Category("Gowtham Custom Properties"),
System.ComponentModel.DefaultValue("")]
public string/int/Date _Value
{
get { return _value; }
set { _value = value; }
}
{
get { return _value; }
set { _value = value; }
}
Ø In the Above scenario we can provide values
statically especially for dropdown control.
Ø and we can't generate events for respected controls and those are
limited controls to overcome these limitations we have to inherit few abstract
classes and we have to override few methods from those abstract classes.
Abstract classes to customize
webpart properties are :
o
Editor Part
o
IWebEditable
o Microsoft.SharePoint.WebPartPages.ToolPart
With EditorPart Class and IWebeditable Interface :
Ø
first we have to create one separate .cs file for that webpart
to create control in editor webpart pane.
Ø
that class must inherited from Editorpart Class.
Ø
From that class we should override following methods:
ü CreateChildControls()
ü SyncChanges()
ü ApplyChanges()
ü we have to
override other methods from different classes
as per requirement.
The controls are added in the CreateChildControls method. This is where you should
place most of your control logic, in editor parts, web parts etc.
The SynChanges method
is used by the EditorPart to get the values from the Web Part into the Editor
Part.
The ApplyChanges method
is executed when you click Ok or Apply and is
used to set the property values of your Web Part. SyncChanges is always called
directly after the ApplyChanges method, to make sure that the properties are in
sync.
Ø
From IWebeditable interface we have to override
CreateEditorparts()
Ø The CreateEditorParts method is used to tell the web part
zone what editor parts you will show, in this case we only have one. But more
advanced web parts may require that you have several. (this method must used in
webpart.ascx.cs file)
Step by Step
Procedure to Create Custom Webpart properties Webpart :
1.
Create New Visual WebPart of sharepoint2013
2.
add WPEditor.cs file to the webpart(another .cs
file )
3.
write code in WPEditor with inheriting the class
Editorpart.
4.
Override Onint() to initialize user controls
with static/dynamic values from sources
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
DropDownList ddlTop = new
DropDownList();
SPWeb
oWeb = SPContext.Current.Web;
SPList
list = oWeb.Lists["QPDES Top Navigation"];
SPQuery
Topquery = new SPQuery();
Topquery.Query = "<Where><IsNull><FieldRef
Name='parentLink' /></IsNull></Where>";
SPListItemCollection Topcol = list.GetItems(Topquery);
foreach
(SPListItem item in Topcol)
{
ddlTop.Items.Add(item.Title);
}
}
v
In above code we get the values from SPList to
the dropdown
this control is added in criateChildControl(). in
this we can provide any data, here we take dropdown but you can take any
control.
5.
Then override the CriateChildcontrols()
protected
override void CreateChildControls()
{
base.CreateChildControls();
this.Controls.add(UserControlObj);
}
6.
Then override ApplyChanges()
public override bool
ApplyChanges()
{
QPDES_ContentDisplayWP webPart = this.WebPartToEdit as
QPDES_ContentDisplayWP;
if
(webPart != null) //Webpart class object
to assign values to proporties of webpart main class
{
webPart.Top
=User control object.value attribute //top is property in
main webpart class
}
return
true;
}
7.
Then Override Sycchanges()
public override void SyncChanges()
{
QPDES_ContentDisplayWP webPart = this.WebPartToEdit as
QPDES_ContentDisplayWP;
if
(webPart != null)
{
UserControlOBJ.Value Atribute = webPart.Top; // top is the property from main webpart class
}}
8.
Then implement the IWebEditable to the .ascx.cs
class of the webpart
9.
Create Properties to get the values from user
controls
public string Top { get; set; }
10.
Then override the CreateEditorParts()
public override
EditorPartCollection CreateEditorParts()
{
List<EditorPart> editorParts = new List<EditorPart>();
WPEditor
oWPEditor = new WPEditor(); //object of
controls created class
oWPEditor.ID = this.ID + "_sampleEditorPart";
oWPEditor.Title = "Personalize";
editorParts.Add(oWPEditor);
return
new EditorPartCollection(base.CreateEditorParts(), editorParts);
}
11.
Then override the Webbrowsable() from IWebeditable
object IWebEditable.WebBrowsableObject
{
get {
throw new NotImplementedException(); }
}
v
Now you
can assign that property value (public string Top {
get; set; }) ,where you want and this is selected value of dropdown in webpart
properties.
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeleterpa Training in Chennai
rpa Training in bangalore
rpa Training in pune
blueprism Training in Chennai
blueprism Training in bangalore
blueprism Training in pune
iot-training-in-chennai
Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
ReplyDeleteData Science Training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune
Data Science training in kalyan nagar
Data Science training in OMR
selenium training in chennai
I have visited this blog first time and i got a lot of informative data from here which is quiet helpful for me indeed.
ReplyDeletepython training in velachery
python training institute in chennai
Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting.So know it's helpful.
ReplyDeleteBlueprism training in btm
Blueprism online training
You blog post is just completely quality and informative. Many new facts and information which I have not heard about before. Keep sharing more blog posts.
ReplyDeleteangularjs Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
angularjs-Training in velachery
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteAWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR
Content is clear and understandable. Waiting for more updates.
ReplyDeleteAngularjs course in Chennai
Angularjs Training in Chennai
Angularjs Training institute in Chennai
AWS Training in Chennai
RPA Training in Chennai
UiPath Training in Chennai
This is a very helpful blog for one who needs to learn in a short span of time.
ReplyDeleteSpoken English in Adyar
Spoken English Classes in Palavakkam
Spoken English Classes in Besant Nagar
Spoken English Institute near me
Spoken English in Porur
Spoken English Class in Virugambakkam
Spoken English Training in DLF
This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
ReplyDeleteAws Cloud Training in Bangalore
Aws Coaching Centre in Bangalore
cloud computing training institutes in bangalore
best cloud computing training in bangalore
cloud computing certification in bangalore
I am happy to find this post Very useful for me, as it contains lot of information
ReplyDeletebloggydirectory
Guest posting sites
Brilliant ideas that you have share with us.It is really help me lot and i hope it will help others also.update more different ideas with us.
ReplyDeleteSalesforce Training in Perambur
Salesforce Training in Mogappair
Salesforce Training in Ashok Nagar
Salesforce Training in Nungambakkam
This comment has been removed by the author.
ReplyDeleteWonderful blog, it has lot of information to me. Continue sharing more like this.
ReplyDeleteData Science Course in Chennai
Data Analytics Courses in Chennai
AWS course in Chennai
Angularjs course in Chennai
RPA course in Chennai
UiPath Training in Chennai
Blue Prism Training in Chennai
DevOps Training in Chennai
Amazing Post. The content is very interesting. Waiting for your future updates.
ReplyDeleteXamarin Training in Chennai
Xamarin Course in Chennai
Xamarin Training
Xamarin Course
Primavera Training in Chennai
Primavera Course in Chennai
IELTS coaching in Chennai
IELTS Training in Chennai
I recently came across your blog and have been reading along. I thought I would leave my first comment.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Python online training
uipath online training
Awesome Post. Great way of sharing the thoughts. Waiting for your future updates.
ReplyDeleteNode JS Training in Chennai
Node JS Course in Chennai
Node JS Advanced Training
Node JS Training Institute in chennai
Node JS Training Institutes in chennai
Node JS Course
Node JS Training in Velachery
Node JS Training in Tambaram
Great Applause. The content you shared is very inspirational. Thanks for Posting.
ReplyDeleteBlockchain certification
Blockchain course
Blockchain courses in Chennai
Blockchain Training Chennai
Blockchain Training in Anna Nagar
Blockchain Training in T Nagar
Blockchain Training in OMR
Blockchain Training in Porur
I think this is one of the most significant information for me. And i’m glad reading your article. Thanks for sharing!
ReplyDeleteLearn Hadoop Training from the Industry Experts we bridge the gap between the need of the industry. Softgen Infotech provide the Best Hadoop Training in Bangalore with 100% Placement Assistance. Book a Free Demo Today.
Big Data Analytics Training in Bangalore
Tableau Training in Bangalore
Data Science Training in Bangalore
Workday Training in Bangalore
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
ReplyDeletesap hana courses in bangalore
sap hana classes in bangalore
sap hana training institute in bangalore
sap hana course syllabus
best sap hana training
sap hana training centers
best sap hana training
Awesome,Thank you so much for sharing such an awesome blog.
ReplyDeletesap hr courses in bangalore
sap hr classes in bangalore
sap hr training institute in bangalore
sap hr course syllabus
best sap hr training
sap hr training centers
sap hr training in bangalore
Pretty! This was a really wonderful post. Thank you for providing these details.
ReplyDeletecloud computing training institutes in bangalore
cloud computing training in bangalore
best cloud computing training institutes in bangalore
cloud computing training course content
cloud computing training interview questions
cloud computing training & placement in bangalore
cloud computing training center in bangalore
Thank you for sharing such a nice and interesting blog with us regarding Java. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle.
ReplyDeleteJava training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
Very informative ..i suggest this blog to my friends..Thank you for sharingthanks a lot
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
Very nice post!!
ReplyDeleteAndroid Training in Chennai
Android Online Training in Chennai
Android Training in Bangalore
Android Training in Hyderabad
Android Training in Coimbatore
Android Training
Android Online Training
Thanks for a marvelous posting! I seriously enjoyed reading it, you are
ReplyDeletea great author.I will be sure to bookmark your blog and will often come back in the future.
I want to encourage yourself to continue your great job, have a
nice weekend!
sap training in chennai
sap training in velachery
azure training in chennai
azure training in velachery
cyber security course in chennai
cyber security course in velachery
ethical hacking course in chennai
ethical hacking course in velachery
When I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.
ReplyDeletedata science training in chennai
data science training in tambaram
android training in chennai
android training in tambaram
devops training in chennai
devops training in tambaram
artificial intelligence training in chennai
artificial intelligence training in tambaram
This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
ReplyDeletejava training in chennai
java training in omr
aws training in chennai
aws training in omr
python training in chennai
python training in omr
selenium training in chennai
selenium training in omr
You completed certain reliable points there. I did a search on the subject and found nearly all people will agree with your blog.
ReplyDeletedata science course in hyderabad
betmatik
ReplyDeletekralbet
betpark
mobil ödeme bahis
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
EXG2Z1
https://bayanlarsitesi.com/
ReplyDeleteAltınşehir
Karaköy
Alemdağ
Gürpınar
APYİ
Kocaeli
ReplyDeleteDenizli
Bursa
istanbul
Van
M5AG
ankara
ReplyDeletesakarya
tekirdağ
kastamonu
amasya
8HRQK8
adıyaman
ReplyDeletesakarya
yalova
tekirdağ
amasya
Q15
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
BA11
uşak evden eve nakliyat
ReplyDeletebalıkesir evden eve nakliyat
tokat evden eve nakliyat
kayseri evden eve nakliyat
denizli evden eve nakliyat
MFE8GW
7101D
ReplyDeleteSakarya Parça Eşya Taşıma
Urfa Parça Eşya Taşıma
Muğla Evden Eve Nakliyat
Afyon Şehir İçi Nakliyat
Yobit Güvenilir mi
Kayseri Evden Eve Nakliyat
Çankırı Parça Eşya Taşıma
Adıyaman Lojistik
Mardin Parça Eşya Taşıma
D8759
ReplyDeleteBurdur Lojistik
Mexc Güvenilir mi
Ünye Çekici
Bilecik Evden Eve Nakliyat
Yozgat Şehirler Arası Nakliyat
Sakarya Parça Eşya Taşıma
Kucoin Güvenilir mi
Yozgat Evden Eve Nakliyat
Yenimahalle Parke Ustası
4CEBA
ReplyDeleteAfyon Şehirler Arası Nakliyat
Bitget Güvenilir mi
Siirt Lojistik
Bilecik Şehirler Arası Nakliyat
Dxgm Coin Hangi Borsada
Karaman Evden Eve Nakliyat
Çankaya Fayans Ustası
Jns Coin Hangi Borsada
Bingöl Evden Eve Nakliyat
52601
ReplyDeletePursaklar Fayans Ustası
Afyon Parça Eşya Taşıma
Mith Coin Hangi Borsada
Meta Coin Hangi Borsada
Wabi Coin Hangi Borsada
Osmaniye Parça Eşya Taşıma
Kars Lojistik
Aksaray Lojistik
Çerkezköy Sineklik
447D1
ReplyDeleteYozgat Parça Eşya Taşıma
Isparta Şehirler Arası Nakliyat
Tokat Lojistik
Denizli Evden Eve Nakliyat
Aptos Coin Hangi Borsada
Karapürçek Parke Ustası
Sonm Coin Hangi Borsada
Kastamonu Evden Eve Nakliyat
Çerkezköy Oto Lastik
1D263
ReplyDeleteÇerkezköy Evden Eve Nakliyat
order sustanon
Erzincan Evden Eve Nakliyat
Mersin Evden Eve Nakliyat
testosterone propionat for sale
Tokat Evden Eve Nakliyat
buy anapolon oxymetholone
masteron for sale
testosterone propionat for sale
8F84E
ReplyDeletebinance
58B67
ReplyDeleteniğde mobil sohbet siteleri
Nevşehir Rastgele Sohbet Odaları
canlı sohbet
afyon bedava sohbet siteleri
kırşehir canli goruntulu sohbet siteleri
yabancı görüntülü sohbet siteleri
Erzincan Sesli Görüntülü Sohbet
kırıkkale canli sohbet
igdir kadınlarla sohbet
4604F
ReplyDeletegümüşhane bedava sohbet odaları
şırnak mobil sohbet siteleri
kars canlı görüntülü sohbet odaları
çanakkale kızlarla canlı sohbet
Bingöl Canlı Sohbet Ücretsiz
bedava sohbet
yalova telefonda kızlarla sohbet
mardin sesli sohbet siteler
adana görüntülü sohbet
8970F
ReplyDeleteücretsiz sohbet uygulaması
urfa en iyi rastgele görüntülü sohbet
Batman Canlı Sohbet Odaları
Nevşehir Bedava Sohbet Uygulamaları
goruntulu sohbet
rastgele sohbet siteleri
en iyi ücretsiz sohbet uygulamaları
niğde bedava sohbet chat odaları
mersin mobil sohbet odaları
724AC
ReplyDeletecanlı sohbet sitesi
erzincan ücretsiz sohbet uygulamaları
çorum ücretsiz sohbet uygulamaları
mersin canlı sohbet odaları
Karabük Kadınlarla Rastgele Sohbet
edirne canli sohbet
niğde görüntülü sohbet odaları
sesli sohbet mobil
ısparta Kadınlarla Görüntülü Sohbet
6D239
ReplyDeleteBinance Ne Kadar Komisyon Alıyor
Floki Coin Hangi Borsada
Periscope Takipçi Satın Al
Görüntülü Sohbet Parasız
Mith Coin Hangi Borsada
Binance Kaldıraçlı İşlem Nasıl Yapılır
Gate io Borsası Güvenilir mi
Twitch İzlenme Satın Al
Shinja Coin Hangi Borsada
7CD4C
ReplyDeletetrezor suite
ellipal
raydium
avax
uwu lend
shiba
arculus
onekey
zkswap
شركة مكافحة الحمام بالاحساء fUkNl3U5On
ReplyDeleteشركة مكافحة النمل الابيض بالجبيل PUOpFDMkOV
ReplyDelete