0

Hello All,
I am presently working on a developed website and want to add some functionality to it.

I have a file called AssetPreview.ascx and the code behind the file as AssetPreview.ascx.cs

Now,

i added something to the ascx file like,

<a id="test" onclick = "temp()" runat="server" >Click here to download the file</a>

and so i added the method temp in the AssetPreview.ascx.cs as,

public void temp(object sender, EventArgs e)
{
//some functionality
}

Is this is correct way to do this..because when i click that link i am getting an run time error saying

Microsoft JScript runtime error : Object Expected

should i do anything else ???

Can any 1 please help me...
Edit/Delete Message

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Renukavani
0

If u use onserverclick then u will get this error
"No overload for method 'temp' takes '0' arguments"

Instead of that u can go for server control with onclick.

<asp:Button ID="btnClick" Text="Click" runat="server" 
            onclick="btnClick_Click" />

Codebehind

protected void btnClick_Click(object sender, EventArgs e)
    {

    }

OR

If u want html control then u need to go for Javascript function like this,

<input type="button" name="btn" value="Click" onclick="onclickEvent();" />

Invoke javascript function,

]<script language="javascript" type="text/javascript">
        function onclickEvent() {
            alert("Hai");
        }
    </script>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.