Sunday, 5 August 2012

Error Solving



37)How to reset all value using JS

Ans:-
function PageUnload1()
{
   document.getElementById('<%=hndFlag.ClientID %>').value="1";
   document.getElementById("btnsubmit").disabled=true;
}
 window.history.forward();
  function noBack(){ window.history.forward(); }
 
function ResetAll()
{

       document.getElementById("<%=txtName.ClientID %>").value="Name*";
       document.getElementById("<%=txtPhoneNo.ClientID %>").value="Phone No.*";
       document.getElementById("<%=txtEmailId.ClientID %>").value="Email Id.*";        
       document.getElementById("<%= ddlCourse.ClientID %>").value = "Select Course";
       document.getElementById("<%= ddlCity.ClientID %>").value = "Select City";
       document.getElementById('<%=hndFlag.ClientID %>').value="0";
//       document.getElementById("<%=txtName.ClientID %>").focus();
       document.getElementById("btnsubmit").disabled=false;
}


<body  onload="ResetAll();" onunload="PageUnload1();" onpageshow="if (event.persisted) noBack();" >





36)How to pass value null in DB
ans:-
   if (objStarEntitys.CourseInterested != "Select Course")
       objSqlCommand.Parameters.AddWithValue("@Course", objStarEntitys.CourseInterested);
       if (objStarEntitys.City != "Select City")
      objSqlCommand.Parameters.AddWithValue("@City", objStarEntitys.City);


35)multilne text box  assign max length
Ans:- Validation For Multiline Textbox
  <script type="text/javascript" language="javascript">
   
  
    var count = "200";
     function limiter()
     {
       var tex =document.getElementById("<%= TextBox3.ClientID %>").value;
       var len = tex.length;
       if(len > count)
        {
          tex = tex.substring(0,count);
          document.getElementById("<%=TextBox3.ClientID %>").value =tex;
          return false;
        }
     }
      </script>
<asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine" onKeyUp="javascript:limiter();" ></asp:TextBox>






33) When Page directive error occurred ?
Ans:-Check (Codebehind in source code ,cs page namespace, root name  whould be same)
32)Multilingul application in page name and resx file name should be same required  ?
:- file name is default.aspx.en-US.resx then aspx file name it should be Defalult.aspx
Need to match start word before second (.).
31)When leed collection are going that time what to be seated?
And date parameter should be (dt=resultdate)
30)When master page error will occure control tag not inside of sever
Ans:- set Fom with runat =server  …error will resolve
*) After submit show javascript msg  with textbox name  from server side.
Ans;-           
ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Message stored successfully..."+TextBox1.Text+"');", true);



1)Generic Principle
Ans:-1st take global.asax file after u have to proceed on next  task


2)Executing Page another page has startup but one page is executing automatically 
Ans:-    delete  these  contentes       <authorization>
                     <allow roles="admin"/>
                     <deny users="?"/>
<deny user=”*”/>
                     </authorization>
After this error  solved
3) Why we are using  this.  Kye word
Ans:-
4)Application State:-
Ans:-global storage mechanism that accessesible for  all web pages



4)Rediobutton blank
   rdlMF.Items[0].Selected = false;
            rdlMF.Items[1].Selected = false;
5)compare validater
if(ValidatecheckPasss(document.getElementById("TextBox7"),document.getElementById("TextBox8"),'RePassword')==false)
        return false;
function ValidatecheckPass(S1,S2,msg)
          {
         
      if(S1.value!=S2.value)
      {
        alert('password and repassword should be same'+msg+'.');
        return false;
        }
}
Or
<Script Language="javascript">
void comp()
{
string str1=TextBox1.Text;
string Str2=TextBox2.Text;
if(str1==str2)
{
MessageBox.Show("Invalid Password");
}
}

6) Age Validation
Ans:- if(Validatecheckforblank(document.getElementById("TextBox3"),'Age')==false)
        return false;
       

function ValidateForAge()
{
 if((document.getElementById("txtAge").value <18) || (document.getElementById("txtAge").value>28) )
      {
        document.getElementById("txtAge").value="";
         document.getElementById("txtAge").focus();
        alert('Please enter 18 to 28 age.');
        return false;
 }     }
7)
How to start and stop moving image on mouse curscr movement
In html tags?

Ans:= onmouseover="this.stop()" onmouseout="this.start()"


a7) How to upload File
if (FileUpload1.HasFile)
            {
                    string abspath=MapPath("~/NewFolder1/"+FileUpload1.FileName);
                    FileUpload1.SaveAs(abspath);
                Label4.Text="Uploaded successfully";
            }
            else
            {
                Label4.Text = "please select File ";
           if (FileUpload1.HasFile)
            {
                string abspath = MapPath("~/NewFolder1/" + FileUpload1.FileName);
                FileUpload1.SaveAs(abspath);
                Label4.Text = "upload successfully";
            }             
            else
            {
                Label4.Text = "plz select file";
            }

8)Stored procedure couldnot find (spname)
Ans:= check database in current opration,
Alter to sp ,check tblname

8)How to get the number 1+ from database
alter  procedure USP_Select1_PersnalInfos
as
begin
select max(no)+1 as no from tblEmpInfo
end 
9)when record stored after Redio button should be Blank
rblMF.Items[0].Selected=false;
             rblMF.Items[1].Selected = false;
validation of redio button
function ValidateForGender()
{
 if((document.getElementById("rblMF").value!=0) && (document.getElementById("rblMF").value!=1) )
      {
         document.getElementById("rblMF").value="";
         document.getElementById("rblMF").focus();
        alert('Please select Gender.');
        return false;
 }     }

Calling  function
if(ValidateForGender(document.getElementById("rblMF"),'Gender')==false)
           return false;






10) validations only for number
function ValidateNumber(S1,msg)
{
    var x=S1.value;
    var num= parseFloat(trimAll(S1.value));
    if(x!='')
    {
        var i;
        for (i = 0; i < x.length; i++)
         {  
        // Check that current character is number.
           var c = x.charAt(i);
           if (((c < "0") || (c > "9")))
           {
             alert("Please enter valid "+ msg+".")
             S1.focus();
             S1.value="";
             return false;
           }
         }
         if(num==0)
            {
            alert("Please enter valid "+ msg+".");
            S1.focus();
            S1.value="";
            return false;
            }
            // Now it allows 12 digits in mobile number  : HARISH 7-12-2009
        if (x.length>2 ||x.length<2)
        {
         alert("Please enter 10 to 11 digits for "+msg+".");
         S1.focus();
         return false;
        } 
     }     
}
After Call a function and pass control id…..
11)
Or
function Validateage(S1,msg)
{
    var x=S1.value;
    var num= parseFloat(trimAll(S1.value));
    if(x!='')
    {
        var i;
        for (i = 0; i < x.length; i++)
         {  
        // Check that current character is number.
           var c = x.charAt;
           if (((c < "0") || (c > "9")))
           {
             alert("Please enter valid "+ msg+".")
             S1.focus();
             S1.value="";
             return false;
           }
         }
 if(num==0)
            {
            alert("Please enter valid "+ msg+".");
            S1.focus();
            S1.value="";
            return false;
            }
            // Now it allows 12 digits in mobile number  : HARISH 7-12-2009
      
        if (x<18)
        {
         alert("Minimun Age is allowed 18"+msg+".");
         S1.focus();
         S1.value="";
         return false;
        } 
        if(x>70)
        {
         alert("Maximum Age is allowed 70"+msg+".");
         S1.focus();
         S1.value="";
         return false;
        } 
     }     
}
11)disable back button
<script type = "text/javascript" >
function disableBackButton()
{
window.history.forward();
}
setTimeout("disableBackButton()", 0);
</script>

//call onn body
<body onload="disableBackButton();">

12) disable cache value  redirect diff pages.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
            Response.Cache.SetNoStore();
13) redio button male female
//onpage
if(ValidateForGender(document.getElementsByName("rblMF"),'Gender')==false)
             return false;

          if(document.getElementById("DdlRel").value == '0')
          {
             alert('Please select City.'); 
             document.getElementById("DdlRel").focus();        
             return false;
          }
/////jsfile
function ValidateForGender(s1,msg)
{
  for(var i=1;i< s1.length;i++)
  {
     if(s1[i].checked)
     {
       return true;
     }
  }
  document.getElementById("rblMF").value="";
  document.getElementById("rblMF").focus();
  alert('Please select Gender.');
  return false;
}
15)stroe error in database using Try catch block
//Classfile





      14)Avoid multipleclick

<form onsubmit="return Submit();">
And the method is like,


<script type="text/javascript">

var flag = false;

function Submit()
{
  if (flag)
  {
    return false;
  }
  else
  {
   flag = true;
   return true;
  }
}
</script>


*)if browser error occur ?
Ans:-delete history and all files.
*)DataGrid Update data in DB
Ans:-
protected void Dginfo_UpdateCommand(object source, DataGridCommandEventArgs e)
        {

            //ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: fnShowMessage(); ", true);
            ////System.Web.UI.WebControls.TextBox checkName = new System.Web.UI.WebControls.TextBox();
            ////checkName = (System.Web.UI.WebControls.TextBox)e.Item.Cells[1].Controls[0];

              
            ////System.Web.UI.WebControls.TextBox NoDg = new System.Web.UI.WebControls.TextBox();
            ////    NoDg = (System.Web.UI.WebControls.TextBox)e.Item.Cells[0].Controls[0];
            ////    System.Web.UI.WebControls.TextBox cName = new System.Web.UI.WebControls.TextBox();
            ////    cName = (System.Web.UI.WebControls.TextBox)e.Item.Cells[1].Controls[0];
            ////    SqlCommand cmd = new SqlCommand("USP_UpdateDgInfoDetails", con);
            ////    cmd.CommandType = CommandType.StoredProcedure;
            ////    cmd.Parameters.Add(new SqlParameter("@NoDg", SqlDbType.Int,50));
            ////    cmd.Parameters["@NoDg"].Value = NoDg.Text;
            ////    cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar,50));
            ////    cmd.Parameters["@Name"].Value = cName.Text;
            ////    con.Open();
            ////    cmd.ExecuteNonQuery();
            ////    con.Close();

                Dginfo.EditItemIndex = -1;
                GridViewShowData();

              
        }
15)Avoid multiple click of page submitting
protected void Page_Init(object Sender, EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
            Response.Cache.SetNoStore();
        }
16)Avoid back button to previous page
function disableBackButton()
{
window.history.forward();
}
setTimeout("disableBackButton()", 0);
function test()
<body onload="disableBackButton()">

17)when end of ddl want show data that required this type
<asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel8" runat="server">
                                            <ContentTemplate>
                                                <asp:DropDownList ID="ddlcity" runat="server" CssClass="textfield"
                                                    AutoPostBack="false" onselectedindexchanged="ddlcity_SelectedIndexChanged">
                                                </asp:DropDownList>
                                               
                                            </ContentTemplate>
                                           <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="ddlCountry" EventName="SelectedIndexChanged" />
                                            </Triggers>
                                        </asp:UpdatePanel>

30)Iframe ex one page to another page show saperatly using iframe
Aspx --àI frame --àanother aspx ,button write the code on
Clientscript.RegisterStatupScript(GetType(),”Load”,”<Script type=’text/javascript’ language=’Javascript’> window.parent.location.href ='../Bookingaspx.aspx';</script>");)

No comments:

Post a Comment