Solved

help convert vb.net event into javascript for better user experience

Posted on 2007-12-05
5
564 Views
Last Modified: 2012-05-05
i am using this function below and the user experience sucks because it does a postback.   how can i just create javascript so we dont have to do a postback eachtime the user selects a choice in any radiobutton.  

    Protected Sub RBL_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim RBL As RadioButtonList
        RBL = CType(sender, RadioButtonList)
        If RBL.SelectedItem.Text = "1" Or RBL.SelectedItem.Text = "2" Then
            Me.Panel3.Visible = True
                 
        End If
    End Sub

<asp:RadioButtonList
                                                                                                ID="jmirating" runat="server" AutoPostBack="True"
                                                                                                CssClass="whiteradio" onselectedindexchanged="RBL_SelectedIndexChanged"
                                                                                                RepeatDirection="Horizontal" TextAlign="Left" Width="403px">
                                                                                                        <asp:ListItem Value="5">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="4">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="3">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="2">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="1">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="N/A">-</asp:ListItem>
                                                                                                    </asp:RadioButtonList>
                                                           
0
Comment
Question by:gianitoo
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:divinewind80
ID: 20411361
I assume you are not using AJAX, correct?  I would recommend that you do this.  Check out the link below for details:  

http://www.asp.net/ajax/

One reason why I say this is because you will most likely find it much easier to use an UpdatePanel in AJAX than to try to unhide a hidden panel in Javascript.  Often, I have found, Javascript has issues finding ASP.NET controls that are hidden...
0
 
LVL 1

Author Comment

by:gianitoo
ID: 20411384
i have tried the update panel but there is an issue with my multiview control.  
when i go next  it does not go to the top of the page in the next view.   it is an issue with updatepanel that i can figure out.  i have asked but nobody helps me.  

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23000618.html
0
 
LVL 9

Expert Comment

by:divinewind80
ID: 20411534
I see.

Try sticking the panel in a div, like so:

<div style="visiblity:hidden;" id="div1" runat="server">
<asp:panel runat=server id="panel1" visible="true" />
</div>

The ID and RUNAT are probably necessary... but it may take a little tinkering.  Give it a try and see what happens.  You should be able to reference this div from Javascript.  If you need some ideas on how to trigger the Javascript from a serverside control, let me know.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 20411553
yes i haveno idea how to do it from javascript.  can u provide full code?
0
 
LVL 9

Accepted Solution

by:
divinewind80 earned 500 total points
ID: 20412089
I would suggest something like the following:

-- In HTML --
<script language="javascript">
setInterval("checkchanged()",2500); //this will check every 2.5 seconds

function checkchanged()
{
if(document.getElementById('RBL).selectedIndex==1||document.getElementById('RBL').selectedIndex==2)
{
document.all.div1.style.visibility='block'
}
}
</scipt>

You will have to mess around with this a bit... but the idea is there, at least.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question