What I'm trying to do is to call a function in aspx.cs from aspx file.
JavaScript code: (for which I'm trying to make c# function in aspx.cs file)
function myconfirm() {
var txt;
var x = confirm("confirmation!!");
if (x == true) {
txt = " Your Request is Submitted!";
}
else {
txt = "Verify and Confirm!";
}
document.getElementById("verify").innerHTML = txt;
return false;
}
c# code in aspx.cs: (This is what I'm trying out and getting a error)
namespace TESTING
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void myconfirm(object sender, EventArgs e)
{
string x = "confirmation!!";
string txt;
if (x == "true")
{
txt = "your request is submitted";
}
else
{
txt = "verify and confirm ";
}
}
public void myconfirm1(object sender, EventArgs e)
{
string y="confirmation!!";
string text;
if(y=="true")
{
text="we are tracking your PRN";
}
else{
text="verify and confirm!!";
}
}
}
}
calling it from aspx file:
<asp: Button ID="Button3" runat="server" Text="SUBMIT" OnClick="myconfirm"></asp: Button>
error I'm getting
'myconfirm1' is undefined"
Summarising it:
- DEFINE A ONCLICK METHOD IN ASPX.CS FILE from c#.
- calling it from aspx file.
Problems occurring:
- lack of basic concept of how to exactly write the c# code in aspx.cs file.
And also If anyone can give a brief concept of how to write c# code in aspx.cs to be called from aspx file.