Question

I have default.aspx with a "Submit" Button and a code behind function called as "btn_Submit" which will perform submit action. Once I deploy the application and if there is any logical problem in btn_Submit code, then I can use runat=server script in default.aspx file and I need not go for another deployment.

But When I tried the same for ascx file, it works very well in development environment i.e in VS but when I move the same to Test server, system throws function not defined. I have renamed the existing function name.

So is it possible to add runat=server script and add c# code in ascx file?

Was it helpful?

Solution 3

I am not sure why this happened and still was not able to solve it, So redeployed the application :(

OTHER TIPS

Yes it is possible.. You have to surround your code with markup

    <script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e)
{
  //hello, world!
}
</script>

Take a look to thisquestion! I think it will help you..

But it is really better to separate your code..

Did you tell the button which method to run on submit? With "auto event wireup" it will try to find a "buttonname_Click" method if you didn't specify anything. If that doesn't exist, you will get an error.

To call a method with a different name, specify that in the OnClick property of the button.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top