Solved

Unable to retrieve div innerHTML value using server side code

Posted on 2006-11-27
3
2,720 Views
Last Modified: 2008-01-09
Dear all,
            I am using C# web form. I am storing some value from data base to my div tag on page load. I update div value using java script . Finally I want to validate the update value in the server side. I am unable to get updated value in the server side. Can anyone help me to solve the problem.

CODE

<DIV id="sc_lbEmpCurCount" style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" runat="server"
            ms_positioning="FlowLayout"></DIV>

Page load server side code
sc_lbEmpCurCount.InnerHtml = iShowCount.ToString();  

using javasript i Update the value

Server Side code
iCurrCount = Convert.ToInt32(sc_lbEmpCurCount.InnerHtml); // I am getting intial value but I want update value




0
Comment
Question by:cosKarthik
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
jay_gadhavi earned 125 total points
ID: 18025644
Try this

I give u an example to solve the problem : it's work perfectly

Html and Javascript



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DivProblem.aspx.vb" Inherits="DivProblem" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="javascript">
function callme()
{
alert(document.getElementById("sc_lbEmpCurCount").innerHTML);
document.getElementById("sc_lbEmpCurCount").innerHTML=""
document.getElementById("sc_lbEmpCurCount").innerHTML="hello from inner html";
document.getElementById("text1").value=document.getElementById("sc_lbEmpCurCount").innerHTML
alert(document.getElementById("sc_lbEmpCurCount").innerHTML);
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
   
    <button id="butt1" name="butt1" value="click Here" runat=server onclick="javascript:callme();" ></button>
   
    <DIV id="sc_lbEmpCurCount" style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" runat="server"  ms_positioning="FlowLayout">
    jayendra
    </DIV>
    <input type=text value="jay" name="hello" id="text1" runat="server"  />
        </form>
</body>
</html>



Server side code :


Partial Class DivProblem
    Inherits System.Web.UI.Page
    Public ishowcount = 29
    Public iCurrCount = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            sc_lbEmpCurCount.InnerHtml = ishowcount.ToString()
            text1.Value = sc_lbEmpCurCount.InnerHtml
        End If

    End Sub
    Public Sub shouwcount()
        iCurrCount = Convert.ToInt32(sc_lbEmpCurCount.InnerHtml) ' // I am getting intial value but I want update value
    End Sub

    Protected Sub butt1_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) handles butt1.ServerClick
        text1.Value = sc_lbEmpCurCount.InnerHtml
    End Sub
End Class

Regards,
jay

0
 
LVL 3

Expert Comment

by:jay_gadhavi
ID: 18025678
If u want the innerhtml value then dont call the butt1_serverclick method (with deleteling the handles or whole method)
0
 

Author Comment

by:cosKarthik
ID: 18026025
I have used hidden control instead of text box
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Title # Comments Views Activity
return false must be hit after calling certain command 10 32
jQuery force form POST 7 44
How do I show metrics with PHP or Javascript 6 31
on window close, not beforeunload 6 17
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 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