Hi all,

1) I am trying to use Ajax and Jquery on master page. In my existing project i have used the Ajaxpro.dll it's working fine. but when i am trying to use jquery then it throws error "Object doesn't support this property or method."

2)I have taken a fresh project if i use jquery on masterpage then the effects are working fine. but when i am trying to add ajaxpro.dll then its shows the error "Masterpage" is undefined."

In both the cases on masterpage i have to use the Ajaxpro.dll. along with that I have to use jquery.

This is my Jquery script of master page.

<script language="javascript" type="text/javascript">
$(document).ready
(
    function()
    {
        $(mnu).hide();
        $(mnu1).hide();
        $(mnu2).hide();
        $(mnu3).hide();
        $(mnu4).hide();
        $(SubMnu).hide();
        $(SubMnu1).hide();
    }
)
$(document).click
(
    function()
    { 
        $(mnu).hide('slow');
        $(mnu1).hide('slow')
        $(mnu2).hide('slow')
        $(mnu3).hide('slow');
        $(mnu4).hide('slow');
        $(SubMnu).hide('slow');
        $(SubMnu1).hide('slow');
    }
)
        
function showMnu()
{
   $(mnu).show('slow');
   $(mnu1).show('slow');
   $(mnu2).show('slow');
   $(mnu3).show('slow');
   $(mnu4).show('slow');
}

function show(id)
{
     if(id == mnu)
     {
           $(SubMnu).show('slow');
     }
     else
     {
           $(SubMnu1).show('slow');
     }
}       
</script>

In below mentioned code i have called server side ajaxmethod "MasterPage.pl_chkmail" , MasterPage.HomeLink_Click, MasterPage.changepasword_Click , MasterPage.Logout_Click on client side.

<script language="javascript" type="text/javascript">
    
    setTimeout("chk_Mail()", 4000)
    
    var a;
    var chk = null;
    function chk_Mail()
    {
        var userid= <%=Session("UserLogged") %>
        var chat=0;
        chat=<%=Session("Chatadmin") %>
        if(<%=Session("PartnerId")%> == 10)
        {
            var ds=MasterPage.pl_chkmail(userid,chat)
            var sqlds=ds.value;
            if (sqlds==true)
            {
                if(chk==null || chk.closed)
                {
                    chk=window.open('Chat.aspx','_blank','width=500,height=420,left=310                    ,top=220,resizable=no')
              
                }
            }
                    
            a = setTimeout("chk_Mail()", 8000);
        }
    }

function redirect_default()
{
    var userid= "<%=Session("UserLogged") %>"
    var usertypeid="<%=Session("UserTypeId") %>"
    var chk = MasterPage.HomeLink_Click(userid)

    if (chk.value == 1)
    {
        if (usertypeid  == 7)
        {
             window.location="Visaprocess_mst.aspx"
        }
        else
        {
            window.location="default.aspx"
        }    

    }
}

function redirect_changepassword()
{
 var userid= "<%=Session("UserLogged") %>"
    var chk = MasterPage.changepasword_Click(userid)

    if (chk.value == 1)
    {
        window.location="ChangePassword.aspx"
    }
}

function redirect_logout()
{
var userid= "<%=Session("UserLogged") %>"
    var chk = MasterPage.Logout_Click(userid)

    if (chk.value == 1)
    {

        window.location="loginform.aspx"
    }

}

</script>

Below code is my code behind of masterpage.

Option Explicit On
'
Imports System.Data
Imports System.Data.SqlClient
Partial Class MasterPage
    Inherits System.Web.UI.MasterPage

#Region "My Variable Declarations"

    Dim sqlCmd As SqlCommand
    Dim sqlDs As DataSet
    Dim acc As DataAccessLayer

    Dim rghts As ChkRights

    '
    Dim vl_UsrId As Integer
    Public SqlCon As New SqlConnection(ConfigurationManager.AppSettings("connectionString"))

#End Region

#Region "Events - Mixed General "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AjaxPro.Utility.RegisterTypeForAjax(GetType(MasterPage))
        Response.Cache.SetNoStore()
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        If Session("PartnerId") <> 10 Then
            chat.Visible = False
            menu.Visible = False
        Else
            chat.Visible = True
            If Session("UserTypeId") = 1 Or Session("UserTypeId") = 2 Then
                menu.Visible = True
            End If
        End If
        If CStr(Session("UserName")) = "" Then
            Session.Abandon()
            Response.Redirect("Partneroptions.aspx")
            Exit Sub
        End If
    End Sub
#End Region

#Region "My ClientSide  Procedures & Functions"
    <AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)> _
           Public Function pl_chkmail(ByVal user As Integer, ByVal chatadmin As Integer) As Boolean
        Dim bStatus As Boolean = False
        '
        Try
            Dim chatid As Integer
            sqlDs = New DataSet
            sqlCmd = New SqlCommand
            '
            Dim sqladp As New SqlDataAdapter(sqlCmd)
            sqlCmd.Connection = SqlCon
            '
            If (SqlCon.State = ConnectionState.Closed Or SqlCon.State = ConnectionState.Broken) Then
                SqlCon.Open()
            End If
            '
            If chatadmin <> 1 Then
                With sqlCmd
                    .CommandText = "usp_chkmail"
                    .CommandType = CommandType.StoredProcedure
                    .Parameters.Add("@user", SqlDbType.Int).Value = user
                    .Parameters.Add("@chatid", SqlDbType.Int).Direction = ParameterDirection.Output

                End With
            Else
                With sqlCmd
                    .CommandText = "usp_chkadminmail"
                    .CommandType = CommandType.StoredProcedure
                    .Parameters.Add("@user", SqlDbType.Int).Value = user
                    .Parameters.Add("@chatid", SqlDbType.Int).Direction = ParameterDirection.Output
                End With
            End If
            '
            sqladp.Fill(sqlDs)
            chatid = sqlCmd.Parameters("@chatid").Value
            SqlCon.Close()
            sqladp = Nothing
            '
            If chatid <> 0 Then
                bStatus = True
            Else
                bStatus = False
            End If

        Catch ex As Exception

        Finally
            sqlDs = Nothing
            sqlCmd = Nothing
        End Try

        Return bStatus
    End Function

    <AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)> _
    Public Function HomeLink_Click(ByVal UserId As String) As Integer
        rghts = New ChkRights
        rghts.pg_check_AssignStatus(UserId, 0, 0)
        rghts.pg_check_AssignStatusforchkavail(UserId)
        rghts.pg_check_AssignStatusforcancel(UserId)
        rghts.pg_check_AssignStatusforenquiry(UserId)
        rghts.pg_check_AssignStatusforpayment(UserId)
        Return 1
    End Function
    <AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)> _
    Public Function changepasword_Click(ByVal UserId As String) As Integer
        rghts = New ChkRights
        rghts.pg_check_AssignStatus(UserId, 0, 0)
        rghts.pg_check_AssignStatusforchkavail(UserId)
        rghts.pg_check_AssignStatusforcancel(UserId)
        rghts.pg_check_AssignStatusforenquiry(UserId)
        rghts.pg_check_AssignStatusforpayment(UserId)
        rghts = Nothing
        Return 1
    End Function
    <AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)> _
    Public Function Logout_Click(ByVal UserId As String) As Integer
        rghts = New ChkRights
        rghts.pg_UpdateIsloggedField("", UserId)
        rghts.pg_check_AssignStatus(UserId, 0, 0)
        rghts.pg_check_AssignStatusforchkavail(UserId)
        rghts.pg_check_AssignStatusforcancel(UserId)
        rghts.pg_check_AssignStatusforenquiry(UserId)
        rghts.pg_check_AssignStatusforpayment(UserId)
        rghts = Nothing
        Return 1
    End Function
#End Region
End Class

Many thanks!

__________________
-Ankur

Recommended Answers

All 6 Replies

Oh man.

Post the code on code-tag.

Now i have posted the code in code tag.

Anyone can help me.

Why not use only jQuery for do this?

I can try.

But in my existing project I have already used the Ajaxpro2.dll on my Master page & thats working fine. So I can't remove it i must need that.
along with ajax i have to use jquery.

In my jquery script when instead of $ i have used 'jquery' keyword then jquery scripts are working fine but its effects are not working.
Means when i write jQuery(mnu).show(); then its working but without effect.
and when i am writing jquery(mnu).show('slow'); & its not working. but that function is called becoz i have puted alert on that.

Using only Jquery on master page its working with its effect.

so give me the solution i am waiting for that.

Many thanks!

__________________
-Ankur

plz anyone reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.