1

I wanted the scroll bar to scroll to the bottom when I clicked the Add Dependent linkbutton, and this works. The problem is when the Add Dependent linkbutton is selected after the postback the text “Please fix the following problems:” shows for a second. But, there are no error messages below it. The validation (jQuery-validation plug-in) works normally if there are validation issues.

Thanks.

Here is the relevant asp.net code:

<script type="text/javascript" language="javascript">
    function toBottom(id) {
        document.getElementById(id).scrollTop = document.getElementById(id).scrollHeight
    }

</script>
<div id="divscroll" class="scroll">

</div>

<div id="validationMessageContainer" class="error" >
    <span id="info_dep_fix_problemls">Please fix the following problems:</span>
    <ul></ul>
</div> 

<asp:LinkButton ID="AddDependent" Text="Add Dependent" CssClass="btngeneral" OnClientClick="toBottom('divscroll')"
            OnClick="AddDependent_Click" runat="server" />&nbsp;&nbsp;

C# Code behind:

protected void AddDependent_Click(object sender, EventArgs e)
{
    //Other unrelated code  -- the button has to be server side as we do database connections, etc.
getScrollPosition();
}

protected void getScrollPosition()
    {
        //Sets the scroll position of the divscroll to the bottom on postback
        ClientScript.RegisterStartupScript(this.GetType(), "toBottom", "toBottom('divscroll')", true);
    }

Here is the css for the scrolling div.

div.scroll
{
    -ms-overflow-x:hidden; 
    overflow-x:hidden; 
    -ms-overflow-y:auto; 
    overflow-y:auto; 
    max-height: 400px;
    max-width: 900px;
}
4
  • It is unclear to me what your problem is...
    – jForrest
    Aug 24, 2012 at 19:51
  • 1
    the jQuery Validation error heading is showing up when the AddDependent button is being clicked. There is no data to be validated, and it disappears shortly there after, but it's showing up is irritating. Thanks. Aug 24, 2012 at 20:12
  • I'm heading home for the weekend, I'll be back Monday to review any suggestions. Aug 24, 2012 at 21:42
  • Just noticed that for some reason "Please" in the above code is highlighted in blue, when it should be black like the rest of the string. Aug 27, 2012 at 19:36

2 Answers 2

1

We figured it out, adding the style="display:none" to the validationMessageContainer div, fixed it.

Thanks to everyone who helped.

0

Try to add at the end of the JavaScript a return false; or maby that appear from code behind? It is unclear. You mean jquery validation plugin? If it is a form validatior, the look in to the plugin code.

3
  • This is a comment, not an answer to the question. Aug 24, 2012 at 20:16
  • I tried adding "return false;" to the javascript, and it didn't change anything... Aug 24, 2012 at 21:43
  • If it is possible, try to check how it manifest in a update panel. Aug 24, 2012 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.