-2

I have a asp:customvalidator that calls the function test(sender, args).
I am using an UpdatePanel with ScriptManager.

How can I call it from server side?

I have an asp:customvalidator associated to a control. The js function check which item is selected from that control and modify the length of a textbox. The problem lies when the user load up that page again but with data. I have to run the previous function to update the new length else the customvalidator will validate the old maxlength.

Popplar
  • 279
  • 5
  • 15
  • 1
    If you're using MVC, you might as well run the javascript on page-load. If you're not, you could look into using something like SignalR. – ProgrammingLlama May 09 '18 at 08:10
  • Im using asp.net webforms. I have created an asp:customvalidator but I also want to execute that function from server side from a method for example. – Popplar May 09 '18 at 08:25
  • 3
    Possible duplicate of [Calling JavaScript Function From CodeBehind](https://stackoverflow.com/questions/5731224/calling-javascript-function-from-codebehind) – Liam May 09 '18 at 08:28
  • All those examples are function without parameters, I need to send (sender, args), the sender should be the control that I want to modify but the event args? – Popplar May 10 '18 at 09:56

1 Answers1

0

Try this.

Page.ClientScript.RegisterStartupScript(this.GetType(), "Text", "function()", true);
Gagan Deep
  • 1,508
  • 9
  • 13
  • My function is sending (sender, args). If I call it from a method I created, shouldn't I be sending something to function()? – Popplar May 09 '18 at 15:34