Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

864 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

24 Experts available now in Live!

Get 1:1 Help Now