+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Creating a form

Creating a form

2 posts, 0 answered
  1. Kevin
    Kevin avatar
    1 posts
    Registered:
    26 Mar 2009
    30 Mar 2009
    Link to this post
    I want to create a simple form on the web site that allows users to request product information.

    When the user hits Submit, the form data gets written to the database (either the Sitefinity db, or my own), and possibly an e-mail notification is sent to me.

    How do I do this?  Can I do this using the built-in facilities, or do I have to create my own module?

    Thanks.
    - Kevin
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    31 Mar 2009
    Link to this post
    Hello Kevin,

    There are two ways that I could come up.

    Use ASP.NET - nothing related to Sitefinity.

    Sample code

           // connect to database 
           string conntectionString = "your connection string here"
           SqlConnection connection = new SqlConnection(conntectionString); 
           connection.Open(); 
           // insert values in a table 
           string query = "INSERT INTO ..."
           SqlCommand command = new SqlCommand(query); 
           // close connection 
           connection.Close(); 
     
     
           // send emial 
           MailMessage message = new MailMessage(); 
           // get the values from the form and send an email 
           message.Subject = TextBox1.Text; 
           SmtpMail.Send(message); 


    If your module that uses products is Generic Content based you can use Sitefinity API to request and content and again send email to an user/administrator. If you take this approach you can create a drop down that is populated with your products - the user should select a product from the drop down/textbox and when press submit you will receive an email with selected content.

    Sample code

        // if GC 
           ContentManager manager = new ContentManager("News"); 
           IList listofAllItems = manager.GetContent(); 
           foreach (IContent content in listofAllItems) 
           { 
               string title = content.GetMetaData("Title").ToString(); 
               if (title == TextBox1.Text) 
               { 
     
                   // send mail here 
                   Response.Write("some text here"); 
               } 
           } 


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
2 posts, 0 answered