使用C#访问DIV标签 [英] Accessing a DIV Tag with C#

查看:61
本文介绍了使用C#访问DIV标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 for(int i = 0; i <     InsCarr.Count;     i ++) 
 
                                        { 
 
                                                mydata   +   InsCarr [i ] .InsCarrierName   +< div  <  >  /div  > ;
                     } 




请告诉我们如何将DIV标签传递给C#?
遵循这种方式对C#可行吗?
< div< br></div>"

如果我使用给定的方法,我得到的结果如下...


孔雀÷/div; cdfasdf< div></div> asdfsdf< div> br</div" f< div>> div>动物div
/div>坏div

/div> sdf


/div> df


;/div> dfg< br></div>

但是,我需要结果是...

cdfasdf
孔雀
动物
bad

解决方案

必须插入div标签并设置两个重要属性runat和id
如:
< div id ="div1" runat ="server"/>
或使用面板
< asp:panel id ="pnl1" runat ="server"/>


此问题已解决.

标签放在循环的前面...

下面的正确代码...


 Response.Write(" div  样式 位置:absolute; background-color:#D1FFFF;宽度:150px;高度:150px;' > );

                        for(int i = 0; i <     InsCarr.计数;     i ++) 
 
                                          { 
 
                                                  mydata     =   InsCarr [i] .InsCarrierName;    //    +< div  <   br  >  <  /div  > ;
                            如果(ReturnTextbox!= null&& ReturnTextbox.Trim().Length> 0)
                            {
                                //写到默认页面,并带有选择选项.
                                如果(MyDiv == null || MyDiv.Trim().Length == 0)
                                {
                                    Response.Write(" div  鼠标悬停  =   \"  this.style.cursor   ='  pointer' ; \"     +  
                                                                   " onmouseout   =   \"  =' 指针' ; \"     +  
 
                                                                   " onclick   =   \"     +  
 
                                                                    ReturnTextbox.Trim()     +    ','"     +  
 
                                                                    mydata     +       ''); \" 字体 尺寸  ='  2' 面孔  Tahoma'  >  <   B  > );

                                }
                                别的
                                {
                                    Response.Write(" div  鼠标悬停  =   \"  this.style.cursor   ='  pointer' ;     \"   +  
                                                                       "onmouseout   \"   this.style.cursor   =' ; \""  +  
                                                                       "onclick   \"   SetTextbox('"  +  
                                                                        ReturnTextbox.Trim()    +    ','"   +  
                                                                        mydata         '"  +  
 
                                                                        MyDiv       > "+
                                          "字体 尺寸  ='  2' 面孔  Tahoma'  >  <   B  > "+ mydata +" <  /B  >  <  /font  > "+
                                          "<  /div  > " );
                                }
                            }
                            别的
                            {
                                Response.Write(" div  <  字体   大小  ='  2' 脸部  Tahoma ' >  <   B  > "+
                                    mydata +"/B  <  /font  >  <  /div  > );
                            }
                        }
                        Response.Write("/div   for(int i = 0; i <     InsCarr.Count;     i ++) 
                                      { 
 
                                             我数据    +   =   InsCarr [i] .InsCarrierName   +< div   id   ='  div1'   运行率  =' >   br  <  > ;
                      } 




还有,

 Response.Write(" . style.position = ' 绝对'; this.style.cursor ='pointer'; \" + 
                                    "  this.style.cursor = '  指针'; \" + 
                                    "  SetTextbox(' "+ 
                                    ReturnTextbox.Trim()+ "  +
                                    mydata + " > " < font size = '  2'face ='Tahoma'>< B>" + 
                                    mydata +
                                    "  +
                                    " )


;

mydata是文本框值....

但是,它没有设置为文本框.


for (int i = 0; i < InsCarr.Count; i++)

                     {

                         mydata += InsCarr[i].InsCarrierName +"<div><br></div>";
                     }




Please tell about how to pass the DIV tag to C#?
following this way is possible to C#?
"<div><br></div>"

If I used the given way, I got the result is below...


peacock<div><br></div>cdfasdf<div><br></div>asdfsdf<div><br></div>f<div><br></div>animal<div><br></div>bad<div><br></div>sdf<div><br></div>df<div><br></div>dfg<div><br></div>

but, I need the result to be...

cdfasdf
peacock
animal
bad

解决方案

must be insert div tag and set two important properties runat and id
such as:
<div id="div1" runat="server" />
or use panel
<asp:panel id="pnl1" runat="server"/>


This problem is solved.

tag is placed to infront of Loop...

the correct code below...


Response.Write("<div style='position:absolute; background-color:#D1FFFF ; width:150px; height:150px;'>");   

                        for (int i = 0; i < InsCarr.Count; i++)

                        {

                            mydata = InsCarr[i].InsCarrierName;  // +"<div><br></div>";
                            if (ReturnTextbox != null && ReturnTextbox.Trim().Length > 0)
                            {
                                //Write to default page, with selection options.
                                if (MyDiv == null || MyDiv.Trim().Length == 0)
                                {
                                    Response.Write("<div onmouseover=\"this.style.cursor='pointer';\"" +

                                        "onmouseout=\"this.style.cursor='pointer';\"" +

                                        "onclick=\"SetTextbox('" +

                                        ReturnTextbox.Trim() + "','" +

                                        mydata + "', '');\">" +
                                        "<font size='2' face='Tahoma'><B>");

                                }
                                else
                                {
                                    Response.Write("<div onmouseover=\"this.style.cursor='pointer'; \"" +

                                          "onmouseout=\"this.style.cursor='pointer';\"" +

                                          "onclick=\"SetTextbox('" +

                                          ReturnTextbox.Trim() + "','" +

                                          mydata + "', '" +

                                          MyDiv + "');\">" +
                                          "<font size='2' face='Tahoma'><B>" + mydata + "</B></font>" +
                                          "</div>");
                                }
                            }
                            else
                            {
                                Response.Write("<div><font size='2' face='Tahoma'><B>" +
                                    mydata + "</B></font></div>");
                            }
                        }
                        Response.Write("</div>");

                    }
                    else
                    {
                        return;
                    }


hi ClassCoder...

thankx for your reply..

i followed your code. but, it is not set to TextControl.

i below in my code..

for (int i = 0; i < InsCarr.Count; i++)

                      {

                          mydata += InsCarr[i].InsCarrierName +"<div id='div1' runat='server'><br></div>";
                      }




Also,

Response.Write("<div onmouseover=\"this.style.position='absolute';this.style.cursor='pointer'; \"  " +
                                    "onmouseout=\"this.style.cursor='pointer';\"" +
                                    "onclick=\"SetTextbox('" +
                                    ReturnTextbox.Trim() + "','" +
                                    mydata + "', '');\">" +
                                    "<font size='2' face='Tahoma'><B>" +
                                    mydata +
                                    "</B></font>" +
                                    "</div>")


;

mydata is textbox value....

but, it is not set to textbox.


这篇关于使用C#访问DIV标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆