开发者

Is it possible to access tags located in a partial view from my css file (external file)?

开发者 https://www.devze.com 2022-12-21 21:11 出处:网络
Let\'s say, I\'ve got this. <div id = \"myDiv\"> <% Html.RenderPartial(\"MyUserControl\"); %>

Let's say, I've got this.

<div id = "myDiv">
   <% Html.RenderPartial("MyUserControl"); %>
</div>

and inside my partial view, I've got this.

<% = htm.TextBox("myTextBox")%>

How can I style this tag from my Site.css file under Content folder? For instance, I want the back ground color to b开发者_Go百科e green.

Thanks for helping


I guess if I did not get an answer until now, it's probably because I didn't ask clearly my question. Anyway, after hours of struggling, I found out how to deal with this.

The following tag <% Html.RenderPartial(string); %> is just a placeholder. So when the page executes, everything is merged (Master page, the view itself, the partial page, etc.). That implies I can target any element anywhere from my external css file by just keeping in mind the real location of that element in the final document.

for instance,

<div id="myDiv"> <% Html.RenderPartial("myPartialView");%></div>

inside mypartial view, i've got this,

<input type="submit" value = "Go"/>

I can access my input element this way:

#myDiv input { background:blue;}

Because, in reality, when the application executes, the whole document will present like this

<div id="myDiv">
     <input type="submit" value = "Go"/>
</div>

Hope that I didn't write falsehood.Otherwise correct me.

Thanks for helping.

0

精彩评论

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