View Single Post
  #1 (permalink)  
Old April 1st, 2005, 04:52 AM
mehdi62b mehdi62b is offline
Friend of Wrox
Points: 1,351, Level: 14
Points: 1,351, Level: 14 Points: 1,351, Level: 14 Points: 1,351, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default Firing server side events at client side codes

Hi Experts,

I have a simple WebForm it has a TextBox

my TextBox has OnChange Event and its AutoPostBack property is true,

now what I want to accomplish is to make a Button to raise this event for me at client side(with javascript)

when I view the source of my ASP.NET page it is something like bellow,
Code:
<script language="javascript">
<!--
    function __doPostBack(eventTarget, eventArgument) {
        var theform;
        if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
            theform = document.forms["Form1"];
        }
        else {
            theform = document.Form1;
        }
        theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
        theform.__EVENTARGUMENT.value = eventArgument;
        theform.submit();
    }
// -->
</script>

            <input type="submit" name="Button1" value="Button" id="Button1" />
            <button id="mahdi" type="button" language="javascript" onclick="document.Form1.TextBox1.onchange();">
                mehdi</button>
            <input name="TextBox1" type="text" onchange="__doPostBack('TextBox1','')" language="javascript" id="TextBox1" />

            <span id="Label1">Label</span>
        </form>
what I did ,I made a simple button(runat=server) and for its onclick I execute the TextBox onchange attribute

this is the tag I used for my button to raise the server side event,

<button id="mahdie" type="button" onclick="document.Form1.TextBox1.onchange();">

now when I test my page the OnChange event at server side doesn't fire

any opinion?

Thanks in advance.

_____________
Mehdi.
software student.
__________________
_____________
<font color=\"teal\"><font size=\"1\"><b>Mehdi.
software student.</b></font id=\"size1\"></font id=\"teal\">
Reply With Quote