quilla_b
06-27-2006, 03:55 AM
hi guys!
i have a problem which involves javascript and asp.net.
this is my current situation:
1. i have a repeater, where the itemtemplate is custom made via a separate class (unarchtemplate.cs) inheriting itemplate.
2.in unarchtemplate.cs, i created an imagebutton web control where the imagebutton has an attributes.add("onclick", "unarchivestudy("+ id+");") property.
3. the attribute on the imagbutton calls the javascript unarchivestudy(id); function in the aspx, passing the "id" value along with it.
4. the unarchivestudy() function basically is supposed to (1) set the value of an htmlinputbutton control (btnUnArchive) on the aspx, to the value of the id (meaning btnUnArchive.value = id) (2) simulate the .click() on the button.
5. the htmlinputbutton "btnUnArchive" has an "onserverclick=btnUnArchive_serverclick()" property which is linked to a method in codebehind.
the problem:
when i set the value of btnUnArchive to the new "id" value, and then the .click() is simulated on the button, the btnUnArchive_serverclick() method in the code behind does not read the new value of btnUnArchive. it retains the old value of btnUnArchive.
I need to get the new value set in the javascript function to reflect in the object parameter of the btnUnArchive_serverclick() method.
what i know:
1. the unArchiveStudy() method receives the id value correctly cuz i called a javascript alert() that displayed the value of the id.
2. the changing of the value of btnUnArchive is also successful because i printed the before and after values of btnUnArchive.
Finally, heres the code:
<script language='javascript'>
function UnArchiveStudy (mrgridid)
{
alert('mrgridid = '+ mrgridid);
alert('before = ' + document.getElementById("btnUnArchive").value);
document.getElementById("btnUnArchive").value = mrgridid;
alert('after = ' + document.getElementById("btnUnArchive").value);
document.getElementById("btnUnArchive").click();
}
</script>
the htmlinputbutton, btnUnArchive, inside the body and form tags
<input id=btnUnArchive type="button"
style="display:none" value="test" runat="server" onserverclick="btnUnArch_ServerClick">
the code behind, onserverclick() method
protected void btnUnArch_ServerClick(object sender, System.EventArgs e)
{
PerformUnArchive(((HtmlInputButton)sender).Value.ToString());
}
thanks!
i have a problem which involves javascript and asp.net.
this is my current situation:
1. i have a repeater, where the itemtemplate is custom made via a separate class (unarchtemplate.cs) inheriting itemplate.
2.in unarchtemplate.cs, i created an imagebutton web control where the imagebutton has an attributes.add("onclick", "unarchivestudy("+ id+");") property.
3. the attribute on the imagbutton calls the javascript unarchivestudy(id); function in the aspx, passing the "id" value along with it.
4. the unarchivestudy() function basically is supposed to (1) set the value of an htmlinputbutton control (btnUnArchive) on the aspx, to the value of the id (meaning btnUnArchive.value = id) (2) simulate the .click() on the button.
5. the htmlinputbutton "btnUnArchive" has an "onserverclick=btnUnArchive_serverclick()" property which is linked to a method in codebehind.
the problem:
when i set the value of btnUnArchive to the new "id" value, and then the .click() is simulated on the button, the btnUnArchive_serverclick() method in the code behind does not read the new value of btnUnArchive. it retains the old value of btnUnArchive.
I need to get the new value set in the javascript function to reflect in the object parameter of the btnUnArchive_serverclick() method.
what i know:
1. the unArchiveStudy() method receives the id value correctly cuz i called a javascript alert() that displayed the value of the id.
2. the changing of the value of btnUnArchive is also successful because i printed the before and after values of btnUnArchive.
Finally, heres the code:
<script language='javascript'>
function UnArchiveStudy (mrgridid)
{
alert('mrgridid = '+ mrgridid);
alert('before = ' + document.getElementById("btnUnArchive").value);
document.getElementById("btnUnArchive").value = mrgridid;
alert('after = ' + document.getElementById("btnUnArchive").value);
document.getElementById("btnUnArchive").click();
}
</script>
the htmlinputbutton, btnUnArchive, inside the body and form tags
<input id=btnUnArchive type="button"
style="display:none" value="test" runat="server" onserverclick="btnUnArch_ServerClick">
the code behind, onserverclick() method
protected void btnUnArch_ServerClick(object sender, System.EventArgs e)
{
PerformUnArchive(((HtmlInputButton)sender).Value.ToString());
}
thanks!