Button problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yogarajan
    New Member
    • Apr 2007
    • 115

    Button problem

    hi All

    my form contains lot of text box and 2 button one button is submit button and another one is calendar button when i am click this calendar button calendar is shown. i am creating required field validation for all fields . but this time am click calender show button calendar doesnot shown, but validation control work (ie * keys shown)

    how can i solve this problem
    1.when i am click submit button that times only validation control work,
    2. when i am click calendar button click that time calendar shown

    this is my requirement


    pls give me immd solution

    thanks
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    kindly post the code that you are working on.

    Comment

    • PrakashN
      New Member
      • Sep 2007
      • 43

      #3
      Set ValidationGroup ="Validation " property on all text boxes, Validation controls and submit button. So the validation works with in group.

      Regards,
      Prakash N

      Comment

      • yogarajan
        New Member
        • Apr 2007
        • 115

        #4
        hi My code

        my aspx page
        <--Start here -->
        [code=asp]
        <%@ Page Language="C#" MasterPageFile= "~/MasterPage.mast er" AutoEventWireup ="true" CodeFile="Chang eNote.aspx.cs" Inherits="Chang eNote" Title="Untitled Page" %>
        <asp:Content ID="Content1" ContentPlaceHol derID="ContentP laceHolder1" Runat="Server">
        <table width="100%" cellpadding="0" cellspacing="0" border="1">
        <tr>
        <td>
        <img src="images/marg.jpg" /></td><td align="center" style="width: 486px">
        <strong>Chang e Note</strong></td>
        </tr>
        <tr><td><b>Na me of the Website</b></td><td style="width: 486px">
        <asp:TextBox ID="txtwebsiten ame" runat="server" Width="355px"></asp:TextBox>
        <asp:RequiredFi eldValidator ID="RequiredFie ldValidator1" runat="server" ControlToValida te="txtwebsiten ame"
        ErrorMessage="* "></asp:RequiredFie ldValidator></td></tr>
        <tr><td><b>Requ ested Date </b></td><td style="width: 486px">
        <asp:TextBox ID="txtreqdate " runat="server"> </asp:TextBox>
        <asp:Button ID="Button2" runat="server" Text="calendar" OnClick="Button 2_Click" />
        <asp:RequiredFi eldValidator ID="RequiredFie ldValidator2" runat="server" ControlToValida te="txtreqdate "
        ErrorMessage="* "></asp:RequiredFie ldValidator></td></tr>
        <tr><td><b>Webp age Name</b></td><td style="width: 486px">
        <asp:TextBox ID="txtwebpagen ame" runat="server" Width="355px"></asp:TextBox>
        <asp:RequiredFi eldValidator ID="RequiredFie ldValidator3" runat="server" ControlToValida te="txtwebpagen ame"
        ErrorMessage="* "></asp:RequiredFie ldValidator></td></tr>
        <tr><td colspan="2"><b> Changes Required on Image </b></td></tr>
        <tr><td colspan="2" style="height: 151px">
        <asp:TextBox ID="txtimagecha nge" runat="server" Rows="8" TextMode="Multi Line" Width="724px"></asp:TextBox></td></tr>
        <tr><td colspan="2"><b> Changed Required on Content</b></td></tr>
        <tr><td colspan="2">
        <asp:TextBox ID="txtcontentc hange" runat="server" Rows="8" TextMode="Multi Line" Width="724px"></asp:TextBox></td></tr>
        <tr><td colspan="2"><b> Changes Required on Functionality</b></td></tr>
        <tr><td colspan="2">
        <asp:TextBox ID="txtfunction alitychange" runat="server" Rows="8" TextMode="Multi Line" Width="724px"></asp:TextBox></td></tr>
        <tr><td colspan="2"><b> Requested By</b></td></tr>
        <tr><td>&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;&nbsp;< b>Name</b></td><td style="width: 486px">
        <asp:TextBox ID="txtreqname " runat="server" Width="355px"></asp:TextBox>
        <asp:RequiredFi eldValidator ID="RequiredFie ldValidator4" runat="server" ControlToValida te="txtreqname "
        ErrorMessage="* "></asp:RequiredFie ldValidator></td></tr>
        <tr><td><b>&nbs p;&nbsp;&nbsp;& nbsp;&nbsp;&nbs p;Mail ID</b></td><td style="width: 486px">
        <asp:TextBox ID="txtreqemail " runat="server" Width="355px"></asp:TextBox>
        <asp:RequiredFi eldValidator ID="RequiredFie ldValidator5" runat="server" ControlToValida te="txtreqemail "
        ErrorMessage="* "></asp:RequiredFie ldValidator>
        <asp:RegularExp ressionValidato r ID="RegularExpr essionValidator 2" runat="server" ControlToValida te="txtreqemail "
        ErrorMessage="V alid Email" ValidationExpre ssion="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpr essionValidator ></td></tr>
        <tr><td colspan="2"><b> Authorised By</b></td></tr>
        <tr><td>&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;&nbsp;< b>Name</b></td><td style="width: 486px">
        <asp:TextBox ID="txtappname " runat="server" Width="355px"></asp:TextBox></td></tr>
        <tr><td>&nbsp;& nbsp;&nbsp;&nbs p;&nbsp;&nbsp;< b>Mail ID</b></td><td style="width: 486px">
        <asp:TextBox ID="txtappmail " runat="server" Width="355px"></asp:TextBox>
        <asp:RegularExp ressionValidato r ID="RegularExpr essionValidator 1" runat="server" ControlToValida te="txtappmail "
        ErrorMessage="V alid Email" ValidationExpre ssion="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpr essionValidator ></td></tr>
        <tr><td colspan ="2"></td></tr>
        <tr><td colspan="2" align="center">
        <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button 1_Click" /></td></tr>
        </table>
        <div style="left: 390px; position: absolute; top: 120px">
        <asp:Calendar ID="Calendar1" runat="server" Visible="false" OnSelectionChan ged="Calendar1_ SelectionChange d">
        <SelectedDaySty le BackColor="Blue " BorderColor="Na vy" BorderStyle="So lid" />
        <DayStyle BackColor="#C0C 0FF" BorderColor="Bl ack" BorderStyle="So lid" />
        <OtherMonthDayS tyle BackColor="Silv er" BorderColor="#4 04040" BorderStyle="So lid" />
        <NextPrevStyl e BackColor="Gray " />
        <DayHeaderSty le BackColor="#C0C 0FF" BorderColor="Bl ue" BorderStyle="So lid" />
        </asp:Calendar>
        </div>
        </asp:Content>
        [/code]

        < -- End here -->

        cs code here

        < -- Start here -->
        [code=cpp]
        using System;
        using System.Data;
        using System.Configur ation;
        using System.Collecti ons;
        using System.Web;
        using System.Web.Secu rity;
        using System.Web.UI;
        using System.Web.UI.W ebControls;
        using System.Web.UI.W ebControls.WebP arts;
        using System.Web.UI.H tmlControls;


        public partial class ChangeNote : System.Web.UI.P age
        {
        protected void Page_Load(objec t sender, EventArgs e)
        {

        }
        protected void Button2_Click(o bject sender, EventArgs e)
        {
        if (Calendar1.Visi ble == true)
        {
        Calendar1.Visib le = false;
        }
        else
        {
        Calendar1.Visib le = true;
        }
        }
        protected void Calendar1_Selec tionChanged(obj ect sender, EventArgs e)
        {
        DateTime calseldate=Conv ert.ToDateTime( Calendar1.Selec tedDate);
        txtreqdate.Text = calseldate.ToSt ring("dd-MMM-yyyy");
        Calendar1.Visib le = false;

        }
        protected void Button1_Click(o bject sender, EventArgs e)
        {
        string pstrClientAddre ss = HttpContext.Cur rent.Request.Us erHostAddress;
        string strwebsitename = txtwebsitename. Text;
        DateTime dtreqdate =Convert.ToDate Time( txtreqdate.Text );
        string strwebpagename = txtwebpagename. Text;
        string strimgchange = txtimagechange. Text;
        string strconchange = txtcontentchang e.Text;
        string strfunchange = txtfunctionalit ychange.Text;
        string strreqname = txtreqname.Text ;
        string strreqemail = txtreqemail.Tex t;
        string strapp = txtappname.Text ;
        string strappemail = txtappmail.Text ;

        string imgfilepath = Convert.ToStrin g(Request.Url);
        char[] splitter = { '/' };
        string imgfile="";
        string[] arInfo = new string[100];
        arInfo = imgfilepath.Spl it(splitter);
        //string imgfile;

        for (int x = 0; x < arInfo.Length-1; x++)
        {
        //Response.Write( arInfo[x] + "<br>");
        if (imgfile == "")
        {
        imgfile = Convert.ToStrin g(arInfo[x]);
        }
        else
        {
        imgfile = imgfile + "/" + Convert.ToStrin g(arInfo[x]);
        }
        }

        DataSetmargreqT ableAdapters.Ma rgchangeTableAd apter margchange = new DataSetmargreqT ableAdapters.Ma rgchangeTableAd apter();
        strimgchange = strimgchange.Re place("\n", "<br>");
        strconchange = strconchange.Re place("\n", "<br>");
        strfunchange = strfunchange.Re place("\n", "<br>");
        margchange.Inse rtmargchange(st rwebsitename, strreqname, strreqemail, dtreqdate, strwebpagename, strimgchange, strconchange, strfunchange, pstrClientAddre ss);
        marg margemail = new marg();
        //bool suc = margemail.mailc hangenotesend(s trreqemail, strappemail, strmailsubject, strimgchange, strconchange, strfunchange);
        bool suc = margemail.chang enotemailsend(s trwebsitename, txtreqdate.Text , strwebpagename, strimgchange, strconchange, strfunchange, strreqname, strreqemail, strapp, strappemail, imgfile);
        if (suc == true)
        {
        Response.Redire ct("reqconfirm. aspx?ack=suc");
        }
        else
        {
        Response.Redire ct("reqconfirm. aspx?ack=fail") ;
        }


        }
        }[/code]
        < -- End here -->
        Last edited by Frinavale; May 26 '08, 08:41 PM. Reason: added [code] tags

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          I can't remember much on how to use the Validator controls but I think what you're looking for has something to do with the ValidationGroup Property.

          You could also consider using JavaScript and CSS to make your calendar control visible on your client side instead of doing a page submit. This will save you bandwidth, time, and server resources.

          As a full member you are expected to use [code] tags. In the future please remember these tags when posting code snippets.

          -Moderator Frinny

          Comment

          Working...