views:

67

answers:

3

I have these functions:

function clear(txtvalue)
{

}

function EnableValue (txtvalue, rfvValue)
{

}

    <asp:Button ID="btn1" runat="server" OnClick="btn1_Click" onclientClick =" return clear('"+txtValue.ClientID+'"); Text="Button" />

<asp:Button ID="btn2" runat="server" OnClick="Button1_Click" onclientClick ="return EnableValue ('"+txtValue.ClientID+'",'"+rfvValue.ClientID+'")"; Text="Button" />

I have two functions where I am trying to send an value from my .aspx page (button) to a JavaScript file.

I get an error telling server tag is not well formed.

What is the issue here?

+3  A: 

Hai prince,

"return clear('" + txtValue.ClientID + "');"

"return EnableValue ('" + txtValue.ClientID + "','" + rfvValue.ClientID + "');"

and see what happens whether you can get value of it in javascript function...

Pandiya Chendur
A: 

You should try to set the OnClientClick property in the code side. You try to concatenate strings while defining a server tag, which is unusual. You can add that line to your Page_OnLoad method:

btn1.OnClientClick = "return clear('" + txtValue.ClientID + "');";

...and pay extra attention to quotation marks, they were wrong in the code you supplied, they should be written like the one above.

Eren
i dnt want to do it in .cs part . i need to do it in .aspx side
prince23
A: 

Aside from the messy concatenation, your quotes are messed up. Make sure your javascript ";" is inside the double quotes for onclientClick.

<asp:Button ID="btn1" runat="server" OnClick="btn1_Click" onclientClick =" return clear('" + txtValue.ClientID + "');" Text="Button" />

<asp:Button ID="btn2" runat="server" OnClick="Button1_Click" onclientClick ="return EnableValue ('" + txtValue.ClientID + "','" + rfvValue.ClientID + "');" Text="Button" />
Codewerks