You must Sign In to post a response.
  • Category: ASP.NET

    Mandatory fields, insertion and sending email

    Hi friends,

    1) int i = objBLL.InsertComplaintInfo(DDLComplaintType.SelectedItem.Text, TxtEmail.Text, TxtPhone.Text, DDLPriorityLevel.SelectedItem.Text);

    on successful insert of these details in the table, I should send an email to to apps@gmail.com with the form contents in the body of the email

    How should I do this?

    Question2:
    How do I specify mandatory columns on a form
    Eg: The asterisk (*) prefixed fields are mandatory fields. * Complaint type

    Thanks
    Smitha
  • #619950
    Hi Smitha,

    1) For sending mail, please read here http://kapildeomalhotra.blogspot.com/2009/09/send-mail-in-aspnet-20-using-smtp.html

    It will give you how to send mail.

    2) Use RequiredFieldValidator Control to make the Fields Mandatory.

    e.g

    If you have text field say Name and you want that is required then you can do the following

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
    ForeColor="Red" ControlToValidate="TextBox1"/>

    You can also use the ValidationSummary control to show the error messages.

    Hope that will help

    Happy Coding

    "Please don't forget to Rate this answer if you found it usefull"

    http://www.dotnetspider.com/mentors/86-kapil-deo.aspx

  • #619951
    Hi Refer my resource in DNS resource section it will help you. Download that source and refer it, i have explained send mail from yahoo/gmail with attachments and text box options

    http://www.dotnetspider.com/resources/42951-How-send-email-using-ASP-NET.aspx

    Regards
    N.Ravindran
    Your Hard work never fails

  • #619954
    Hi,

    Reg the mandatory fields,
    I need the * Eg: *Complainttype: Dropdown
    Here the user selects an item from the dropdown. The asterisk (*) prefixed fields are mandatory fields

    Even b4 the validation is done, the asterisk should be shown next to the complainttype label in red

    Thanks for ur help

  • #619956
    Hi,

    You can do the following

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Literal ID="text" Text="*" runat="server"></asp:Literal>

    Happy Coding

    "Please don't forget to Rate this answer if you found it usefull"

    http://www.dotnetspider.com/mentors/86-kapil-deo.aspx

  • #619985
    Hello,
    For email sending check my post in the following link :
    http://dotnetsquare.com/resources/1-Easy-way-To-Send-Mail-with-without-attachment-Through-ASPNet-C-Net-VBNet

    and for mandatory field follow below steps :

    1. For TextBox check below code :

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
    ForeColor="Red" ControlToValidate="TextBox1"/>


    2. For DropDownList follow below steps :
    1. First add one default item which is select when page load.(ex: --Select--)
    2. Now use below code to validate above dropdownlist

    <asp:DropDownList id="DropDownList1" runat="server">
    <asp:ListItem Text ="--Select--" Value ="--Select--" ></asp:ListItem>
    <asp:ListItem Text ="Type1" Value ="Type1" ></asp:ListItem>
    <asp:ListItem Text ="Type2" Value ="Type2" ></asp:ListItem>
    </asp:DropDownList>
    <asp:RequiredFieldValidator ID="reqddl" runat="server" ControlToValidate="DropDownList1" ForeColor="Red" ErrorMessage="*" InitialValue="--Select--"></asp:RequiredFieldValidator>

    If it helps you then Rate this.

    Best Regards,
    Manoranjan Sahoo
    http://www.dotnetsquare.com
    Blog: http://blog.msahoo.net


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.