I know JavaScript and asp.net but this is first time I am using JavaScript in asp.net . I face a little problem.
My problem is JS function isvaliduser() return true or false,all time 'cObj.Save(courseObj)' is called ! I need when JS function return true only that time cObj.Save(courseObj) will call otherwise cObj.Save(courseObj) will not call.
This is my code :
CGateway cObj = new CGateway ();
protected void saveButton_Click(object sender, EventArgs e)
{
CInfo cInfoObj = new CInfo();
cInfoObj.AName= ANameTextBox.Text;
cObj.Save(courseObj);
}
JavaScript :
function isvaliduser()
{
var uid;
var temp = document.getElementById("<%=ANameTextBox.ClientID %>");
uid = temp.value;
if(uid == "")
{
alert ("Please Enter UserName”);
return false;
}
else
{
return true;
}
}
ASPX:
<asp:Button ID="saveButton" runat="server" Text="Save"
OnClientClick ="javascript:isvaliduser()" />
How can I do it? Thank you.
voluntarily removed by its author.