The magic you're looking for is the "contenteditable" attribute. Works in IE, Firefox and Chrome.
I'm not sure what the hell you're doing with this, lmao... but this ought to work:
Your Code Behind:
protected void Page_Load(object sender, EventArgs e)
{
//creating some bogus collection of strings.
string[] parts = { "this", "is", "a", "test", "of", "the", "goofiest", "ui", "ever" };
//bind it to the repeater.
rptr.DataSource = parts;
rptr.DataBind();
//now we'll add them to a JavaScript array we can access client side.
StringBuilder sb = new StringBuilder();
sb.Append("document.stringItems = new Array();");
for (int i = 0; i < parts.Length; i++)
sb.AppendFormat("document.stringItems[{0}] = '{1}';", i, parts[i]);
ScriptManager.RegisterClientScriptBlock(this, GetType(), "someKey", sb.ToString(), true);
}
protected void btnTest_Click(object sender, EventArgs e)
{
//display the result just so we can see it's working.
lblResult.Text = hdnResult.Value;
}
Your .ASPX:
<asp:Repeater ID="rptr" runat="server">
<ItemTemplate>
<span contenteditable="true" style="border: solid 1px;" onkeyup="updateItem(event, <%#Container.ItemIndex%>)">
<%#Container.DataItem%></span>
</ItemTemplate>
</asp:Repeater>
<asp:HiddenField ID="hdnResult" runat="server" />
<asp:Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_Click" />
<script type="text/javascript" language="javascript">
//<![CDATA[
function updateItem(e, index) {
//get the source element. (magic here for cross browser lameness)
var src;
if(window.event) {
e = window.event;
src = e.srcElement;
}else{
src = e.target;
}
//update our item in our array.
document.stringItems[index] = src.innerHTML;
//update our hidden field.
var s = '';
var space = false;
for (var i = 0; i < document.stringItems.length; i++) {
if (space)
s += ' ';
else
space = true;
s += document.stringItems[i];
}
var hdnResult = document.getElementById('<%=hdnResult.ClientID%>');
hdnResult.value = s;
}
//]]>
</script>
<asp:Label ID="lblResult" runat="server"></asp:Label>
You'll have to add some javascript for the onkeypress too to make sure they're not adding carriage returns or spaces or whatever it is you don't want them putting in... but this is the basic idea.
I hope that helps. Good luck.