Advertisement
Advertisement
| 08.11.2008 at 01:30PM PDT, ID: 23639294 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: |
testmainpage.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public ArrayList ControlIdList {
get {
object v = ViewState["ControlIdList"];
return v != null ? (ArrayList)v : null;
}
set {
ViewState["ControlIdList"] = value;
}
}
public int LastControlId {
get {
object v = ViewState["LastControlId"];
return v != null ? (int)v : 0;
}
set {
ViewState["LastControlId"] = value;
}
}
private Hashtable m_controls = new Hashtable();
private void CreateControls() {
ArrayList ids = ControlIdList;
if (ids != null) {
foreach (int id in ids) {
testmainusercontrol control = CreateControl(id);
c_placeHolder.Controls.Add(control);
}
}
}
private testmainusercontrol CreateControl(int id) {
testmainusercontrol result = (testmainusercontrol)LoadControl("testmainusercontrol.ascx");
result.ID = "c_" + id;
result.InsertAbove += InsertRowAbove;
result.InsertBellow += InsertRowBellow;
result.Remove += RemoveRow;
m_controls[id] = result;
return result;
}
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
if (!IsPostBack) {
LastControlId = 1;
ArrayList idList = new ArrayList(1);
idList.Add(0);
ControlIdList = idList;
CreateControls();
}
DisplayResult();
}
private void DisplayResult() {
StringBuilder sb = new StringBuilder();
bool first = true;
foreach (int id in ControlIdList) {
if (!first) {
sb.Append(", ");
}
else {
first = false;
}
testmainusercontrol control = (testmainusercontrol)m_controls[id];
sb.Append(control.Text);
}
c_resultLabel.Text = sb.ToString();
}
protected override void LoadViewState(object savedState) {
base.LoadViewState(savedState);
CreateControls();
}
private void RemoveRow(object sender, EventArgs e) {
testmainusercontrol control = (testmainusercontrol)sender;
int index = control.Parent.Controls.IndexOf(control);
c_placeHolder.Controls.RemoveAt(index);
ControlIdList.RemoveAt(index);
DisplayResult();
}
private void InsertRowAbove(object sender, EventArgs e) {
testmainusercontrol control = (testmainusercontrol)sender;
int index = control.Parent.Controls.IndexOf(control);
CreateControlAt(index);
DisplayResult();
}
private void InsertRowBellow(object sender, EventArgs e) {
testmainusercontrol control = (testmainusercontrol)sender;
int index = control.Parent.Controls.IndexOf(control) + 1;
CreateControlAt(index);
DisplayResult();
}
private void CreateControlAt(int index) {
int id = GetNewId();
testmainusercontrol newControl = CreateControl(id);
ControlIdList.Insert(index, id);
c_placeHolder.Controls.AddAt(index, newControl);
}
private int GetNewId() {
int id = LastControlId++;
return id;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder runat="server" ID="c_placeHolder"></asp:PlaceHolder>
<br />
<asp:Label ID="c_resultLabel" runat="server" Text="Label"></asp:Label><br />
<asp:Button ID="c_postBackButton" runat="server" Text="Do PostBack!" /></div>
</form>
</body>
</html>
testmainusercontrol.ascx
<%@ Control Language="C#" ClassName="testmainusercontrol" %>
<script runat="server">
public event EventHandler InsertAbove;
public event EventHandler InsertBellow;
public event EventHandler Remove;
protected void InserAboveClick(object sender, EventArgs e) {
if (InsertAbove != null) {
InsertAbove(this, e);
}
}
protected void InsertBellowClick(object sender, EventArgs e) {
if (InsertBellow != null) {
InsertBellow(this, e);
}
}
protected void RemoveClick(object sender, EventArgs e) {
if (Remove != null) {
Remove(this, e);
}
}
public string Text {
get {
return c_textBox.Text;
}
}
</script>
<div>
<span style="width: 200px;">
<asp:TextBox runat="server" ID="c_textBox" />
</span><span>
<asp:Button runat="server" ID="c_insertAboveButton" Text="Insert Above" OnClick="InserAboveClick" />
<asp:Button runat="server" ID="c_insertBellowButton" Text="Insert Bellow" OnClick="InsertBellowClick" />
<asp:Button runat="server" ID="c_removeButtom" Text="Remove" OnClick="RemoveClick" />
</span>
</div>
|