views:

85

answers:

1

I want to Set the Horizontal Scrollbar slider to the right without using css direction:"ltr" or dir="ltr" or an asp:Panel direction="rightToLeft"....

i just want to access the object that controls the Horizontal scrollbar slider to give it the position. from aspx page or the aspx.cs.

aspx page :

<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/BeginScrollFromRight.js"></script> . . .
<body id="body" style="overflow:auto; height:100%;width:100%;"> . . . </body>

js page :

function BeginScrollFromRight() 
{
  $("#body").scrollLeft($(window).width());
}

I need to have the same effect for the direction:rtl but only for the horizontal scrollbar because other object are not supported when using direction:rtl

<td id="tdView" runat="server" dir="ltr" align="center">
                        <table onclick="hideMenusComplex();" oncontextmenu="hideMenusComplex();" id="tblView" runat="server">
                            <tr>
                                <td>
                                    <asp:Label ID="lblView" runat="server" ForeColor="#5E82D6" Visible="false"><%= translate("View : ") %></asp:Label>
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    <cc1:Combobox  AlignContainer="Center" ID="ddlViews" runat="server"  OnClientChange="onChangeValue()"
                                        FolderStyle="../EsStyles/ComboXpBlue" AutoPostbackEnable="false" Width ="200">
                                    </cc1:Combobox>
                                </td>
                                 <td>
                                    <asp:Label ID="lblViewArabic" runat="server" ForeColor="#5E82D6" Visible="false"><%= translate("View : ") %></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>

This is the code and the ddlViews is the dropdown list that is opening in a wrong way, the dropdown list is not opening under the control is opening on the left of the control.

+1  A: 

For languages the read right-to-left, direction: rtl is really the only way that will work well, in the end.

If you just want to scroll all the way to the right, jQuery JavaScript like:

$("#YourContentDiv").scrollLeft($("#YourContentDiv").width());

or:

$(window).scrollLeft($(window).width());

will do it.

.
In case you are new to jQuery, you can add it to your page, like this.:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
    function jQueryMain ()
    {
        $("#YourContentDiv").scrollLeft($("#YourContentDiv").width());

        $(window).scrollLeft($(window).width());
    }


    $(document).ready (jQueryMain);
</script>

.
PS: jQuery takes most of the cross-browser hassle out of JavaScript like this.

Brock Adams
when i am using $(window) in a javascript file i'm getting an error : object expected. maybe there's no way to fix this problem
Codeffect
even window.scrollLeft(window.width()); is not working
Codeffect
@Codeffect: Do you have jQuery in your page? See the updated answer for the full solution.
Brock Adams
The horizontal scrollbar slider didn't begin from right to left. still the same problem
Codeffect
@Codeffect: What do you mean, "didn't begin from right to left"? It was just supposed to scroll over, other than that it would be the same because `direction: rtl` was used. Please post your page code and, ideally a sketch of what you want.
Brock Adams
@Codeffect: could you paste the code into your question? And be sure to indent it all 4 spaces so that we can make it out. Or you can use http://pastebin.com/ .If the only reason you are not using `rtl` is because some objects do not suport it, the smart thing would be to use `rtl` and then use jQuery to "fix" just those objects.
Brock Adams
PS: Did you try this style? `head, body {direction: rtl;}`? That is, style both the head and the body, at minimum.
Brock Adams
when i try to put the body {direction: rtl;} it works fine but there's only one problem :a dropdown control is not opening well .it just opens well if the body {direction: ltr;}
Codeffect
Thank you for your help but its really a predicament situation...and i prefer to find a solution without changing the properties of the dropdown.
Codeffect
how to fix the dropdown with the jquery ?
Codeffect
@Codeffect: `"how to fix the dropdown with the jquery"` You have to post code that shows the problem and describe what the actual problem is. When I test an `rtl` page, drop-downs (`<select>` s) work as I expect them to. But of course, I am not directly familiar with any rtl languages.
Brock Adams
i added the drop down list code. now is there a way to move the list under the control with JQuery ?
Codeffect
First, how are you calling `BeginScrollFromRight()`? Are you using ` $(document).ready ()`? You should.Re: `"is there a way to move the list under the control with JQuery?"` Probably. Unfortunately, I no longer develop with Microsoft tools, so I don't know the **generated HTML** for that Combobox control. Can you post the generated html, for this control as it appears on the output page?
Brock Adams
BeginScrollFromRight() is located in a js file .and the aspx page is calling this function on client page load,but i didnt work so i removed it.
Codeffect