Solved

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

Posted on 2007-12-05
5
560 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now