Once encountered such a problem
In a pop-up window
One of my buttons needs to execute two events.
I,
Protected void button#click (Object sender, eventargs E)
{
String revengeboy = "";
Revengeboy = "I'm a killer, marathon, killing and killing every day"; // This is just an example.
}
II,
Then you have to execute this event.
<Script language = "JavaScript" type = "text/JavaScript">
// <! CDATA [
Function inputbutton1_onclick ()
{
Window. dialogarguments. aspnetform. inputroles. value = '<% = revengeboy %>'; // return the value
Window. Close (); // close the window
}
//]>
</SCRIPT>
It is depressing that onclientclick is executed first than onclick. To achieve the method onclientclick = "inputbutton#onclick ()" onclick = button#click in the execution script, this is totally ineffective.
And I think that
Protected void button#click (Object sender, eventargs E)
{
Getselectedroles ();
This. button1.attributes. Add ("onclick", "javascript: inputbutton1_onclick ()");
}
In this way, the effect can be achieved, but it is not very outrageous if I make a mistake. How can this problem be achieved only by pressing the button twice;
Final method:
However, after having gone through these several mistakes, I think it is only possible to write him to the background page...
Protected void button#click (Object sender, eventargs E)
{
Getselectedroles ();
Response. Write ("<SCRIPT> window. dialogarguments. aspnetform. inputroles. value = '" + revengeboy + "'; window. Close (); </SCRIPT> ");
} Well, this has achieved what I want. Haha !!!
Private void getselectedroles () // find the control from the gridview and obtain the value
{
Foreach (gridviewrow row in gridview1.rows)
{
// This. lable3.text + = + (row. findcontrol ("label2") as label). text;
// Itemname = itemname + (Label) gridview1.rows [row. rowindex]. findcontrol ("label2 ")). text ;//. cells [4]. controls [0]). text. trim ();
Roles = (Label) gridview1.rows [row. rowindex]. cells [1]. findcontrol ("txtrolename"). Text. tostring ();
Checkbox CB1 = (checkbox) gridview1.rows [row. rowindex]. findcontrol ("checkbox4 ");
Checkbox CB2 = (checkbox) gridview1.rows [row. rowindex]. findcontrol ("checkbox5 ");
Checkbox CB3 = (checkbox) gridview1.rows [row. rowindex]. findcontrol ("checkbox6 ");
If (cb1.checked = true | cb2.checked = true | cb3.checked = true)
{
If (cb1.checked = true)
{
Read = "R-Y ";
}
Else
{
Read = "R-N ";
}
If (cb2.checked = true)
{
Write = "W-Y ";
}
Else
{
Write = "W-N ";
}
If (cb3.checked = true)
{
Update = "U-Y ";
}
Else
{
Update = "U-N ";
}
Itemname = itemname + roles + "," + read + "," + write + "," + update + "| ";
}
}
This. label3.text = itemname. tostring ();
}