开发者

cross client and server

SendMessage.aspx

<asp:DropDownList  runat="server" ID="listMessagereceiver"></asp:DropDownList>
<textarea id="txtBodyMessage" name="txtBodyMessage">    </textarea>
<asp:Button OnClick="btnSendMessage_Click" runat="server" ID="btnSendMessage"  />

Script

CKEDITOR.replace( 'txtBodyMessage',{language : 'fa',on :{}} );

Code

protected void Page_Load(object sender, EventArgs e)
{
  listMessagereceiver.DataSource=list;
  listMessagereceiver.DataBind();
}
protected void btnSendMessage_Click(ob开发者_高级运维ject sender, EventArgs e)
{
 //how can access to `txtBodyMessage`
}

txtBodyMessage is client side how can access this?

This is a good way for send message?

Is there a better way؟


If you just want the value that was posted, nothing else, then request.form["txtBodyMessage"] will work.

Alternatively, <textarea id="txtBodyMessage" name="txtBodyMessage" runat="server"> </textarea> would give you more control as a server htmlcontrol. This works as a half-way house.

Finally there's make it a full web control as pj suggested above but use clientid to find out what it called in the page, not id. ID is the server side control name.


Assuming your script is on a ASPX page you could change the text area to:

<asp:TextBox id="txtBodyMessage" name="txtBodyMessage" MultiLine="True" runat="server">    </asp:TextBox>

and your javascript to:

CKEDITOR.replace( '<%=txtBodyMessage.ClientID %>',{language : 'fa',on :{}} );

and then in your event handler:

protected void btnSendMessage_Click(object sender, EventArgs e)
{
 //access `txtBodyMessage` with this.txtBodyMessage
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜