Friday, 16 December 2011

Ajax Slider Show Extender Control Image Click Event

Question:-Ajax Slider Show Extender Control  Image Click Event i want to do somthing ?


Answer:-

.aspx

<%-- Below image is  Slider Show Image --%>

 <a onclick ="popshow();" href ="#" >
    <asp:Image runat ="server" ID ="img1"   /></a>

<%-- Below Script get image url   --%>

<script language ="javascript" type ="text/javascript">
    function popshow() {
        var img = new Image();
        var x = document.getElementById('<%=img1.ClientID%>').src;
      alert(x);
 
//if u pass image url to code behind window  write var z  method
        var z = "<%=chkup(" + x + ")%>";
        alert(z);
//if u pass image  url  as query string
window.location.href='yourwebsitelocation?a='+x+';

            }
   
</script>

.aspx.cs

  public static string chkup(string url)
    {
      return "good";
    }



Monday, 3 October 2011

how to handle window close event in javascript in chrome also

Question:-How to handle window close event in java Script in chrome also
Answer:-
<script>window.onbeforeunload = function() { alert("here U r functionality");}
</script>

how to handle window close event in javascript

Question:-How to handle window close event in java Script
Answer:- <html>
<body onbeforeunload="alert('Closing');">
</body>
</html>

Thursday, 22 September 2011

Open Window with limit size in .net (c#)

Question:- Open new window with limit of size in C#/aspx.cs
Answer:-
string url = "MyNewPage.aspx?ID=1&cat=test";
string fullURL = "window.open('" + url + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no' );";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);

Wednesday, 21 September 2011

How to use two UpdatePanels and one timer control in asp.net

Question:-How to use two UpdatePanels and one timer control in asp.net

Answer:-
  <div >

<asp:Timer ID="Timer1" runat="server" Interval="700" ontick="Timer1_Tick">

</asp:Timer>

   </div>



//First UpdatePanel



       <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional"  runat="server">

       <Triggers>

       <asp:AsyncPostBackTrigger ControlID ="Timer1" EventName ="Tick" />

       </Triggers>

       <ContentTemplate>



       //Here Write u r code        

      

       </ContentTemplate>

       </asp:UpdatePanel>



//Second UpdatePanel



  <asp:UpdatePanel UpdateMode ="Conditional"  ID="UpdatePanel2" runat="server">

       <ContentTemplate >



      //Here Write U r code

      

       </ContentTemplate>

       </asp:UpdatePanel>

    


How to use two updatepanels one timer control

Question:-How to use two updatepanels one timer control

Answer:- 

<div >

<asp:Timer ID="Timer1" runat="server" Interval="700" ontick="Timer1_Tick">

</asp:Timer>

 </div>

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional"  runat="server">     

       <Triggers>

       <asp:AsyncPostBackTrigger ControlID ="Timer1" EventName ="Tick" />      

       </Triggers>

       <ContentTemplate>

              //Here U r Code

              </ContentTemplate>

       </asp:UpdatePanel>



 <asp:UpdatePanel UpdateMode ="Conditional"  ID="UpdatePanel2" runat="server">

       <ContentTemplate >

       //Here U r code

       </ContentTemplate>

       </asp:UpdatePanel>

Sunday, 18 September 2011

Default Button in Panel n't Working in all browser

Question:-Default Button in panel n't working in all browser

Answer:- Write Java Script like this

Script:-

<script>

        function EnterKey(e)

        {            

                // look for window.event in case event isn't passed in

                if (window.event) { e = window.event; }

                if (e.keyCode == 13)

                {

                        document.getElementById('btnchat').click();

                }

        }

        </script>

.aspxCode:-



<asp:TextBox runat ="server"  onkeypress="EnterKey(event);"  ID ="txtchat" TextMode="MultiLine" >

      </asp:TextBox>

  
<asp:Button runat="server" ID ="btnchat" Text ="Send" onclick="btnchatclickevent" />

  

Saturday, 17 September 2011

How to Remove single Session

Question:-
How to Remove single Session

Answer:- Session.Remove("Sessioname");

Tuesday, 13 September 2011

Image Button In Gridview Eevent not fired?

Solution:

<asp:gridview autogeneratecolumns="false" gridlines="None" id="grddoctors" runat="server">

<columns>

<asp:templatefield>

<itemtemplate>

<asp:imagebutton borderstyle="Groove" borderwidth="4" commandargument="100" commandname="DocImage" height="114" id="imgdoc" imageurl="imageurl" oncommand="img_Command" runat="server" width="100">



</asp:imagebutton></itemtemplate>

</asp:templatefield>

</columns>

</asp:gridview>


Sperate Image Event:



protected void img_Command(object sender, CommandEventArgs e)
{
//ur code here
//e.commandargument and e.commandname call here

}

Invalid postback or callback argument

Error:
Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Answer:

Add Property EnableEventValidation="false" in Page tag

Eg:-

<%@ Page EnableEventValidation="false" %>

Friday, 19 August 2011

Auto Complete Control in .Net

Write Code in .aspx Page
<asp:TextBox ID="txtbox1" runat="server"></asp:TextBox>

    <cc1:AutoCompleteExtender

      Enabled="true"

       UseContextKey ="true"

        MinimumPrefixLength ="1"

         ServiceMethod ="getdata"

           CompletionInterval="10"

        TargetControlID ="txtbox1"

     ID="AutoCompleteExtender2" runat="server">

    </cc1:AutoCompleteExtender>

Write a Method in .aspx.cs
using System.Collections.Generic;


[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] Getdata(string prefixText, int count,string contextKey)
{

List <string> response = new List <string>();

for (int i = 0; i =10; i++)
{
response.Add(prefixText+i);

}
return response.ToArray<string>();
}

Thursday, 11 August 2011

Validation of viewstate MAC failed

Error:-

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Answer:-
if u get this error just add attribute EnableViewStateMac="false" in page tag

Example:-<%@ Page Language="C#" EnableViewStateMac="false" >

Tuesday, 9 August 2011

Get lable control text in javascript

var x = document.getElementById('<%=LableId.ClientID %>').textContent;

this work in firefox also

Sunday, 7 August 2011

Sql Server identity

identity
To change identity first drop identity column and then add new identity column like
this example

drop identity column

alter table tb_name
drop column col_name

add identity column

alter table tb_name
add columnname int identity(100,1)