2011-03-14 18 views
-1

実際に私は本のIDを入力して、私のWebページを設計しています。
Nameofthebook。入力し、ボタンをクリックして、書籍が利用可能な別のページに移動し、利用可能ではないエラーメッセージを表示することはできません私のプロジェクト(ライブラリ管理システム)Asp.net SQL Serverのページを検証する方法と設定方法制御を検証し、制御コードの検証を設定する方法...詳細を私に送るAsp.net検証制御コードを使用する方法

My code 
using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
using System.Data.SqlClient; 


public partial class Bookcheck : System.Web.UI.Page 
{ 
     public Int64 Sid; 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     string Id; 
     Id = Request.QueryString.Get(0); 

    if (!(IsPostBack == true)) 
    { 
     if (Request.QueryString.Get(1) == "G") 
     { 
      Sid = Convert.ToInt64(Id); 
      if (PopulatedRecord (Sid) == false) 
      { 

      } 
     } 
    } 
} 
private Boolean PopulatedRecord(Int64 Id) 
{ 
    DataSet DS; 
    DS = new DataSet(); 
    SqlCommand cmd = new SqlCommand(); 
    SqlDataAdapter da = new SqlDataAdapter(); 
    SqlConnection Cnn = new SqlConnection(); 
    string connectionstring; 
    connectionstring = @"Datasource=DEVI\SQLEXPRESS;Intial catalog=librarymanagement;Integrated Security=SSPI"; 
    Cnn.ConnectionString = connectionstring; 
    if (Cnn.State != ConnectionState.Open) 
     Cnn.Open(); 
    cmd.Connection = Cnn; 
    cmd.CommandType = CommandType.StoredProcedure; 
    cmd.CommandText = "usbinsertdatainto"; 
    cmd.Parameters.Clear(); 
    cmd.Parameters.AddWithValue("@bookId",txtid); 
    da.SelectCommand = cmd; 
    try 
    { 
     da.Fill(DS); 
    } 
    catch (Exception ex) 
    { 
     throw new ApplicationException(
      "!!! An Error Occured While Update Record In Dtl_SecurityCapital_Upload." + ex.Message); 
     lblerror.Visible = true; 
     lblerror.Text = "!!! An Error Occured While " + ex.Message.ToString(); 
     return false; 
    } 
    if (DS.Tables[0].Rows.Count > 0) 
    { 
     txtid.Text = DS.Tables[0].Rows[0]["bookId"].ToString(); 
     txtnb.Text = DS.Tables[0].Rows[0]["Nameofthebook"].ToString(); 
    } 
    cmd.Dispose(); 
    Cnn.Close(); 
    Cnn.Dispose(); 
    return true; 
} 


} 
     protected void Button2_Click(object sender, EventArgs e) 
     { 
     if(Page.IsValid) 
     { 
     Response.Redirect ("issueofbook.aspx?bookid="+txtid.Text 

              +"&Nameofthebook="+txtnb.Text); 
      } 
     } 
    }  

        Error 
           Line 59:    throw new ApplicationException(
           Line 60:     "!!! An Error Occured While 
                 Update        

           Record In Dtl_SecurityCapital_Upload." + ex.Message); 
           Line 61:    lblerror.Visible = true; 
            Line 62:    lblerror.Text = "!!! An Error 
               Occured While " +       
                  ex.Message.ToString(); 

行63:return false;

+0

もし笑! (!IsPostBackプロパティ) – Evgeny

+0

場合 – Evgeny

答えて

0

親愛なる、 TextBoxを確認するためにRequiredFieldValidatorASP.NET control)を使用しているかどうかを確認してください。テキストボックスをチェックする または 使用JavaScriptが空かない

マークアップです:

<asp:TextBox ID="txtNo" runat="server" /> 
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="No Required " ControlToValidate="txtNo" /> 
<asp:TextBox ID="txtName" runat="server"></asp:TextBox> 
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Name Required " ControlToValidate="txtName" /> 
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> 

ボタンのクリックイベント:(!(IsPostBackプロパティ==真))

protected void Button1_Click(object sender, EventArgs e) 
{ 
    if (Page.IsValid) 
    { 
     Response.Redirect("~/Newpage.aspx?no=" + txtNo.Text + "&name=" + txtName.Text); 
    } 
} 
+0

@muhammadアクタールplsは私のコード – kannan

+0

@muhammadのアクタールを送信して、次のエラーが 'ライン59を来ていただきありがとうございます@muhammadアクタール私のコード – kannan

+0

を送った:「:新しいApplicationExceptionを( ライン60を投げます! !! Dtl_SecurityCapital_Uploadの更新記録中にエラーが発生しました。 "+ ex.Message); 行61:lblerror.Visible = true; 行62:lblerror.Text = "!!!エラーが発生しました" + ex.Message.ToString(); 行63:falseを返します。 ' – kannan

関連する問題