0

Hi All..
This Code Write On aspx file .This Code set the value in hidden field..But This Code Does not Work Properly

<html><head></head>
    <body>
    <script type= "text/javascript">
        function showDialogue() {
            var a = Screen.Width;
            var b = Screen.hieght;
            document.getElementById('HiddenField1').value = a;
            document.getElementById('HiddenField2').value = b;
        }
    </script>              
    <form id="form1" runat="server"  >
     <asp:HiddenField ID="HiddenField1" runat="server"  />
     <asp:HiddenField ID="HiddenField2" runat="server"  /> 
    </form>
    </body>
</html>

in code Behind ::
On page Load Am Calling JavaScript function.
Page.ClientScript.RegisterStartupScript([GetType](), "MyKey", "showDialogue();", True)
I am also Calling Javascript in Another way:
Dim localScreenWidth As String = " <script type='text/javascript'>showDialogue();</script>"
then retrive The Hidden Field..
Label2.Text = HiddenField1.Value
Label3.text=HiddenField2.value
But I am Not getting any Hidden field value.Give me a Idea ,How I am getting Hiddenfield value???

2
Contributors
1
Reply
5
Views
4 Years
Discussion Span
Last Post by G_Waddell
0

If you have the clientside function already written in the aspx file you don't need to register it server side.

I'm also not sure what you are doing here:

Dim localScreenWidth As String = " <script type='text/javascript'>showDialogue();</script>"

Basically call the javascript clientside to update the hidden field values then in the page post back read the values server side

Remember the page has two sides, Client which is run on the browser and server. The only way the server side knows what is happening client side is if the data page is posted back to the server.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.