<p>OK, I am not sure if the title it completely accurate, open to suggestions!</p>

<p>I am in the process of creating an ASP.NET custom control, this is something that is still relatively new to me, so please bear with me.</p>

<p>I am thinking about the event model. Since we are not using Web Controls there are no events being fired from buttons, rather I am manually calling <strong>__doPostBack</strong> with the appropriate arguments. However this can obviously mean that there are a lot of postbacks occuring when say, selecting options (which render differently when selected).</p>

<p>In time, I will need to make this more Ajax-y and responsive, so I will need to change the event binding to call local Javascript.</p>

<p>So, I was thinking I should be able to toggle the "mode" of the control, it can either use postback and handlle itself, or you can specify the Javascript function names to call instead of the doPostBack.</p>

<ul>
<li>What are your thoughts on this?</li>
<li>Am I approaching the raising of the events from the control in the wrong way? (totally open to suggestions here!)</li>
<li>How would you approach a similar problem?

<hr></li>
</ul>

<h2>Edit - To Clarify</h2>

<ul>
<li>I am creating a custom rendered control (i.e. inherits from WebControl).</li>
<li>We are not using existnig Web Controls since we want complete control over the rendered output.</li>
<li>AFAIK the only way to get a server side event to occur from a custom rendered control is to call doPostBack from the rendered elements (please correct if wrong!).</li>
<li>ASP.NET MVC is not an option.</li>
</ul>

[{'answer_id': 58953, 'author': 'Rob Wells', 'author_id': 2974, 'author_profile': 'https://Stackoverflow.com/users/2974', 'pm_score': 6, 'selected': True, 'text': '<p>You might like to try this <a href="http://www.vim.org/scripts/script.php?script_id=1491" rel="noreferrer">improved Javascript syntax highlighter</a> rather than the one that ships with VIMRUNTIME.</p>\n'}, {'answer_id': 59211, 'author': 'Thomas Kammeyer', 'author_id': 4410, 'author_profile': 'https://Stackoverflow.com/users/4410', 'pm_score': 4, 'selected': False, 'text': '<p>Syntax coloring synchronization probably needs adjustment.  I\'ve found in certain contexts that I need to change it.</p>\n\n<p>Syntax synchronization (":help syn-sync") controls how vim keeps track of and refreshes its parse of the code for coloring, so that it can start drawing anywhere in the file.</p>\n\n<p>The defaults don\'t always work for me, so sometimes I find myself issuing</p>\n\n<pre><code>:syn sync fromstart\n</code></pre>\n\n<p>I suggest reading through the documentation under</p>\n\n<pre><code>:help syn-sync\n</code></pre>\n\n<p>or just check</p>\n\n<pre><code>:help syntax\n</code></pre>\n\n<p>and find the section on synchronization.</p>\n\n<p>to make an informed decision among the four available basic options.\nI maintain mappings to function keys to switch between "fromstart" and "ccomment" modes and for just clearing the sync settings.</p>\n'}, {'answer_id': 59593, 'author': 'AndrewJFord', 'author_id': 6154, 'author_profile': 'https://Stackoverflow.com/users/6154', 'pm_score': 2, 'selected': False, 'text': '<p>For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. <kbd>Ctrl</kbd>+<kbd>L</kbd> for a screen redraw can also fix it.</p>\n'}, {'answer_id': 5652956, 'author': 'Jose Elera', 'author_id': 428786, 'author_profile': 'https://Stackoverflow.com/users/428786', 'pm_score': 4, 'selected': False, 'text': '<p>Well, I\'ve modified <a href="http://www.vim.org/scripts/script.php?script_id=1491">Yi Zhao\'s Javascript Syntax</a>, and added Ajax Keywords support, also highlight DOM Methods and others.</p>\n\n<p>Here it is, it is far from being perfect as I\'m still new to Vim, but so far it has work for me. <a href="http://www.vim.org/scripts/script.php?script_id=3425">My Javascript Syntax</a>. If you can fix, add features, please do.</p>\n\n<p>UPDATE: <strike>I forgot these syntax highlights are only shown if you included them in your own colorscheme, as I did in my <code>Nazca</code> colorscheme. I\'ll test if I could add these line into my modified syntax file.</strike></p>\n\n<p>Follow the new version of the javascript syntax file in <a href="https://github.com/jelera/vim-javascript-syntax">github</a>, for it is no longer required to modify your current colorscheme.</p>\n'}, {'answer_id': 40917247, 'author': 'jorgeh', 'author_id': 1620879, 'author_profile': 'https://Stackoverflow.com/users/1620879', 'pm_score': 3, 'selected': False, 'text': '<p>This is a really old post, but I was experiencing the same thing: sometimes syntax highlight would just stop working when looking at the javascript section in an <code>.html</code> file. As the OP mentions, a quick workaround was to scroll up and then magically things would start highlighting again.</p>\n\n<p>Today I found the underlying problem and a good solution. In Vim, syntax highlighting uses a context to derive the correct highlight, where context is defined by the previous lines. It is possible to specify how many lines before the current line are used by issuing <code>:syntax sync minlines=200</code>. In this case, it will use up to 200 previous lines as context. It is possible to use the whole file (which can be slow for long files) by running <code>:syntax sync fromstart</code>.</p>\n\n<p>Once I found that, I added this line to my <code>.vimrc</code>:</p>\n\n<pre><code>autocmd BufEnter *.html :syntax sync fromstart\n</code></pre>\n\n<p>By doing so, <code>.html</code> files will use the whole file as context. Thus, the javascript section will always by highlighted properly, regardless of how long the JS section is. Hope this helps someone else out there!</p>\n'}]
['https://Stackoverflow.com/questions/58827', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/832/']