Search code examples
c#asp.netbrowserevent-handlingonresize

C# ASP.NET browser resize event


I cannot find a resize event for my C# Asp.Net application. I'm trying to do something like this, but there is no onresize event in my <body runat="server" ..>.

How do I add a function call on the event of browser resize in my C# ASP.NET application?


Solution

  • You need to add your custom resize handler to the window using JavaScript. Something like this.

    <script>
    function customResize(){
      //your code
    }
    
    function onLoad(){
      window.onresize = customResize;
    }
    </script>
    <body onload="onLoad"></body>