Creating Dynamic Widget
Hi All,
I am very new in sitefinity and using sitefinity 6.3 version.
I want to create a Registration Module in Sitefinity.
In registration, i take 4 information(Name,Address,Email & PhoneNo) by user and save these values into our sql database.
Please let me know that how to create a widget for registration module.
Thanks & Regards,
Viky
Hi Viki,
If you need to have those values in your specific database, I would suggest to just create a simple ASP.NET UserControl (.ascx) and create your own logic on catching and inserting the data into the database.
If it is okay to also store those settings inside Sitefinity you have like 2 options:
Does this helps you?
Kind regards,
Daniel
Hi Daniel,
I added TestClass.cs inside the App_code file, but i am not getting this class reference inside the usercontrol. In TestClass.cs, i keep all sql functionality for Insert, Update, Edit & Delete.
Please let me know that how we will manage these type work in usercontrol.
If you have any sample file, please provide me.
Thanks & Regards
Viky
Hi Viky,
Can you share the code you have on the forums? If so, I can take a look and create a sample.
You can email me if you like (check konstrui.nl)
Kind regards,
Daniel
Hi Daniel
<div style="border: 2px solid #7F8400; border-radius: 6px; width: 100%; padding: 5px;">
<div style="padding: 2px; width: 95%">
<div style="float: right; width: 79%">
<asp:TextBox ID="txtName" runat="server" Width="200px" MaxLength="100"></asp:TextBox>
</div>
<div style="float: left; width: 20%; text-align: right;">
<span><b>Name:</b></span>
</div>
</div>
<div style="clear:both;margin-top:5px;"></div>
<div style="padding: 2px; width: 95%">
<div style="float: right; width: 79%">
<asp:TextBox ID="txtEmail" runat="server" Width="200px" MaxLength="150"></asp:TextBox>
</div>
<div style="float: left; width: 20%; text-align: right;">
<span><b>Email ID:</b></span>
</div>
</div>
<div style="clear:both;margin-top:5px;"></div>
<div style="padding: 2px; width: 95%">
<div style="float: right; width: 79%">
<asp:TextBox ID="txtAddress" runat="server" Width="200px" MaxLength="200"></asp:TextBox>
</div>
<div style="float: left; width: 20%; text-align: right;">
<span><b>Address:</b></span>
</div>
</div>
<div style="clear:both;margin-top:5px;"></div>
<div style="padding: 2px; width: 95%">
<div style="float: right; width: 79%">
<asp:TextBox ID="txtPhone" runat="server" Width="200px" MaxLength="12"></asp:TextBox>
</div>
<div style="float: left; width: 20%; text-align: right;">
<span><b>Phone:</b></span>
</div>
</div>
<div style="clear:both;margin-top:5px;"></div>
<div style="padding: 2px; width: 95%">
<div style="float: right; width: 79%">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"/>
</div>
<div style="float: left; width: 20%; text-align: right;">
</div>
</div>
<div style="clear:both;margin-top:5px;"></div>
</div>
Please copy this code put on your user control.
I want to save these value on our database.
Regards,
Viky
Hi Viky,
If you have this code on the frontend, you can use the code-behind of your UserControl to actually execute the code that saves the values into the database.
Frontend.ascx
<
div
style
=
"border: 2px solid #7F8400; border-radius: 6px; width: 100%; padding: 5px;"
>
<
div
style
=
"padding: 2px; width: 95%"
>
<
div
style
=
"float: right; width: 79%"
>
<
asp:TextBox
ID
=
"txtName"
runat
=
"server"
Width
=
"200px"
MaxLength
=
"100"
></
asp:TextBox
>
</
div
>
<
div
style
=
"float: left; width: 20%; text-align: right;"
>
<
span
><
b
>Name:</
b
></
span
>
</
div
>
</
div
>
<
div
style
=
"clear:both;margin-top:5px;"
></
div
>
<
div
style
=
"padding: 2px; width: 95%"
>
<
div
style
=
"float: right; width: 79%"
>
<
asp:TextBox
ID
=
"txtEmail"
runat
=
"server"
Width
=
"200px"
MaxLength
=
"150"
></
asp:TextBox
>
</
div
>
<
div
style
=
"float: left; width: 20%; text-align: right;"
>
<
span
><
b
>Email ID:</
b
></
span
>
</
div
>
</
div
>
<
div
style
=
"clear:both;margin-top:5px;"
></
div
>
<
div
style
=
"padding: 2px; width: 95%"
>
<
div
style
=
"float: right; width: 79%"
>
<
asp:TextBox
ID
=
"txtAddress"
runat
=
"server"
Width
=
"200px"
MaxLength
=
"200"
></
asp:TextBox
>
</
div
>
<
div
style
=
"float: left; width: 20%; text-align: right;"
>
<
span
><
b
>Address:</
b
></
span
>
</
div
>
</
div
>
<
div
style
=
"clear:both;margin-top:5px;"
></
div
>
<
div
style
=
"padding: 2px; width: 95%"
>
<
div
style
=
"float: right; width: 79%"
>
<
asp:TextBox
ID
=
"txtPhone"
runat
=
"server"
Width
=
"200px"
MaxLength
=
"12"
></
asp:TextBox
>
</
div
>
<
div
style
=
"float: left; width: 20%; text-align: right;"
>
<
span
><
b
>Phone:</
b
></
span
>
</
div
>
</
div
>
<
div
style
=
"clear:both;margin-top:5px;"
></
div
>
<
div
style
=
"padding: 2px; width: 95%"
>
<
div
style
=
"float: right; width: 79%"
>
<
asp:Button
ID
=
"btnSubmit"
runat
=
"server"
Text
=
"Submit"
OnClick
=
"btnSubmit_Click"
/>
</
div
>
<
div
style
=
"float: left; width: 20%; text-align: right;"
>
</
div
>
</
div
>
<
div
style
=
"clear:both;margin-top:5px;"
></
div
>
</
div
>
Frontend.ascx.cs
public
partial
class
Frontend : System.Web.UI.Page
protected
void
Page_Load(
object
sender, EventArgs e)
protected
void
btnSubmit_Click(
object
sender, EventArgs e)
// Check if the page is valid ( if you have some validators on the form)
if
(!Page.IsValid)
return
;
// Get the values from the form
var name = txtName.Text.Trim();
var email = txtEmail.Text.Trim();
// TODO: Insert here your code that inserts values into the database
So, when clicking on the submit button, you should do your thing.
Does that makes sense? After that, you should register your new UserControl into your Toolbox to use it on one of your pages. You can do this easily with help of Sitefinity Thunder.
Kind regards,
Daniel