Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in this code i ma trying to create hyperlink and calling javascript function with two parameters on click of hyperlink its not working...it works fine when i pass no parameters..
C#
foreach (DataRow dRow in ds.Tables[0].Rows)
         {
string qry = "SELECT  DISTINCT Sender, Receiver FROM Message WHERE Sender='" + dRow["UserName"].ToString() + "'and receiver = '" + username + "'";

SqlDataAdapter da = new SqlDataAdapter(qry, conn);
            DataSet ds3 = new DataSet();
            da.Fill(ds3);
            conn.Close();
             if (ds3.Tables[0].Rows.Count > 0)
             {
                 sb.Append("<li><a href="" önclick="OpenChatBox(dRow["UserName"].ToString(),dRow["User1"].ToString())">" + dRow["UserName"].ToString() + "</a></li>");

             }
             ChatContent.InnerHtml = sb.ToString();
         }


this is the javascript function which i'm calling...
XML
<script language="javascript">

    function OpenChatBox(sender, receiver) {
        var win = window.open("ChatBox.aspx?agent=" + sender + "&user=" + receiver, "", "status=0,toolbar=0, menubar=0, width=490, height=650");
    }

   </script>
Posted
Updated 2-May-11 5:16am
v2

Pass the values in single quotes
OpenChatBox('"+dRow["UserName"].ToString()+"','"+dRow["User1"].ToString()+"')
 
Share this answer
 
v2
XML
sb.Append("<li><a href =''" + "onclick='OpenChatBox('" + dRow["UserName"].ToString() + "','" + dRow["UserName"].ToString() + "')'>" + dRow["UserName"].ToString() + "</a></li>");

i ma doing it like this .i have just print this it gives output like this
onclick='openchatbox('value','value')'
i think it should be like this but it is not working
 
Share this answer
 
Comments
Steven.Pinto2000 2-May-11 9:44am    
i wud suggest u to create a normal hyperlink n then call the onclik function with two parameters check if it works if it works properly then right click n viewsorce to see if the output which u r gettin is the same as the normal hyperlink output if nothing works use developers tool or debugg the javascript code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900