.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

controling html elements in controler's code

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :ASP.Net
 

Hi. I'm starting to learn mvc2, mainly because my job requires it.

I had a doubt, that even silly is driving me nuts.  I pick up on the nerddinners examples, following Professional.ASP.NET.MVC wrox book.
but now i'm doing some modifications for my own account.
On traditionl ASP.net it was possible to interact with html elements (divs, textbox, etc... )
On MVC 2 is that possible or any interaction with html must be done with jquery and how?  Because i'm trying to manipulate an html element on my Controller page (DinnerController.ASPX and i had no reference to html div, as i initially supose. 

help?  




View Complete Post


More Related Resource Links

dynamically change html code when user is authenticated

  

So I have a fairly simple web site which allows an Administrator to edit some data in a database which is displayed on some web pages.


The main navigation on the site is shown in the code snippet below. The Admin link goes to a Login.aspx which allows the Administrator to log in - once authenticated they get sent to the data edit page.

So my question is, how could I dynamically add a link to the data edit page in the <ul> list below once the user is authenticated ?

This would allow the authenticated user to see links to the secure pages in the main navigation bar.


<%--Top Navigation Menu --%>
<div id="topMenu">
<ul>
<li><a href="default.aspx">Home</a></li>
<li><a href="introduction.aspx">Introduction</a></li>
<li><a href="curriculum.aspx">Curriculum</a></li>
<li><a href="times.aspx">Times & Fees</a></li>
<li><a href="staff.aspx">Staff</a></li>
<li><a href="login.aspx">Admin</a></li>
</ul>
</div><%--End of topMenu Container--%>
<div id="clear"></div><%--Floats items cleared End of Master Page--%>


How do I change the default HTML code for a collection of lists and views

  

I have modified the html display code of some lists and content query web parts in SharePoint designer.  This works well when modifying a few lists, but I have many lists and different views with these many lists.

Is there a way to modify the template code for a site so that all my lists, views and CQWPs display identically with my modified code?  Managing these individually is not practical.


VB.NET - store HTML code in SQL Server

  

Hey guys/gals!!

Quick question - I want to allow someone to enter HTML markup in a control, and save the input exactly as entered. 

I want people to put a minimum of 50 words, to maximum of 500, and be able to save the formatting of their text in SQL 2005 server database. 


Also, I understand this is two questions, but how do I save metadata of an image file in the sql database? I mean, I get the gist of it, but how do I do it? 


Thanks everyone!


Extract text from html source code

  
i wan to extract Desired Title,Desired Text and Desired link from Webpage source code and paste in richTextBox1. <a href="/site/show/link/0/type/0">Desired Titl e</a> <a title="&lt;b&gt;Text preview&lt;/b&gt; &lt;br/&gt;Some Text" class="pdtip" href="/site/show/link/0/type/0">Text</a><br />Desired text <br /> <label class="url" for="">http://Desiredlink.com </label> Output: Desired Title Desired Title Desired link How can i do this?

How to handle differences in HTML code from different browser versions?

  
First of all I'm still very new to C# so be gentle :p I'm currently trying to make an application that can login to a certain website and search for some numbers and so on that I can put in an overview, just to save some time. The only thing I found that could do this is the WebBrowser control, and I've managed to make it work, but when I gave the program to a friend it failed. I think it has to do with the difference in browser versions (he uses Internet Explorer 7, I use the latest) and if that's the case I'm pretty clueless how to deal with the problem, since I don't even know what the differences in HTML codes are in each version, and it seems like a lot of work to adjust all the html code to check for accordingly. For example it was even so that & changed to &amp; in my application on my PC and that's only by using one browser so I dunno what happens with other browser versions. I assume that the WebBrowser control always uses Internet Explorer, even if for example Firefox is the standard browser, is this true? But to be sure I asked the friend to put his Internet Explorer as the default browser and still no go. So my question is: is there a relatively easy way to make sure that the program works on practically any PC, without me having to make exceptions for like version 1.6.7 or 1.6.8 (I have no idea what versions there are really)?

Firexfox and SharePoint Forum - a reply shows html code

  
When users use Firefox to view SharePoint and are replying to a post of the forum\discussion board the reply box and view box already has the HTML code in. For instance the body field contains:- <div><br/><br/><hr/> <b>From: </b>Kevin Shilling<br/> <b>Posted: </b>03 August 2010 15:17<br/> <b>Subject: </b>CHRISTMAS IS COMING...<br/><br/> <div>Yes, I know it is only August but thinking ahead what do you think about hosting our annual Open Evening for local neighbours, suppliers and friends and family. Do you think it is a good idea or not? Let me have your thoughts before the end of September when planning usually starts.</div></div> Anyone come across this and found a fix? Regards Mike

Rich text field showing html code

  
I am an end user of Sharepoint. This issue only happens from my computer, not from any other within our organization. What happens is that when I edit an item in Sharepoint that contains a rich text field, HTML code is showing. Like so: <div class=ExternalClassC900CFF4F2BF4312A89133C01A6E3C96> Some text</div> This happens from any web browser. Sharepoint 2007 is used. I have Windows 7 x64. Any idea what is causing this?

Coding elements in datalist with code behind... Possible?

  
Hey Forumers,I've got a label in the item template tag of the datalist control. The label is bound to an integer column in the data source.What I want to achieve is to retrieve the number from that label and change its text according to what number is retrieved. i.e. if number retrieved = 1 then          lbl.text = "SomeText"My problem is that I don't know how to code that label as it is found in the <ItemTemplate> of the datalist and intellisense cannot identify the label.Is it possible for me to code that label using code behind? or is there any other way to do this?thanks in advanceZephere

How to dynamically create HTML file from the code ?

  
Hi all,Precisely and concisely, I have aspx page that has only one button "Generate". If the user clicked on this button, one HTML page should be created. The created HTML page should have title "Home" and the Body should contain "Hello World". 1) What is the code that should be written inside "Generate" button in order to accomplish this functionality? 2) Assuming the HTML page gets created, How to store it inside specific folder on the local drive? Or how to store it inside DB? I would greatly appreciate any constructive input!

The difference between code behind and front side html

  

Hi,

This is a basic understanding I miss, 

On our aspx page most actions can be done from code behind or from aspx.cs page 

If it is done from aspx.cs page then there is no access to the code , unlike Javascript, css or plain html, for example changing font color can be done both ways:

In code behind:  lblMessage.ForeColor = Drawing.Color.DarkRed

Or in html: style="font-family:verdana;color:DarkRed"

when should I be using code behind and when html?

If the only difference is privacy then why not using only code behind?



How can i save HTML code with developer tools??

  

Hello, all

to insurt pics and change colors in webparts, i changed some HTML code and CSS classes in developer tool. and it works perfect. but the problem is i don't know how to save the code i changed, everytime i went to the other web or close the develop tool, the web i changed will turn to the original one.

there is save button in developer tools, but the file i saved was TXT file rather than HTML file. i know may be i can change it to HTML file directly, but after changed, what i should do, i don't where sharepoint saved all of its html files?? is there any folder that sharepoint use to keep all of it's code??

Thank you inadvance

Yuyu


How can i save HTML code with developer tools??

  

Hello, all

to insurt pics and change colors in webparts, i changed some HTML code and CSS classes in developer tool. and it works perfect. but the problem is i don't know how to save the code i changed, everytime i went to the other web or close the develop tool, the web i changed will turn to the original one.

there is save button in developer tools, but the file i saved was TXT file rather than HTML file. i know may be i can change it to HTML file directly, but after changed, what i should do, i don't where sharepoint saved all of its html files?? is there any folder that sharepoint use to keep all of it's code??

Thank you inadvance

Yuyu


Removing HTML head code

  
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:&

How do I keep SP 2010 from changing my HTML code? It is really ____ me off!!

  

Ok, I am trying to add simple html and css to a text box defined as "Enhanced rich text (Rich text with pictures, tables, and hyperlinks)"

But everytime I save and close SP changes the HTML. It is really starting to make me MAD. can I turn that "Feature" off? I am trying to add something as simple as this.

<hr noshade="true" width="1px" /> but SP keeps changing it to <hr width="1px" />

or

<div style="background-image:url('imgs/main_headr.jpg');"> </div>

but SP keeps removing the style all together.

 

I am experiencing this in CEWP's as well as pages.


how will take the html controls value from source code to code behind of asp.net page

  

i created a calendar user control in asp.net+c#.it have two html text boxes and one img button.but i dont know ,how will take
the values to code behind of asp.net from html text boxes values at runtime on the onclick of html img button.....Any ideas????.

This is my main code

 CalendarUserControl.ascx

      <div>View from:</div>
         <div>  <input type="text" name="showdia" id="showdia" size="9" value="10/04/2010"><input onclick="return showCalendar('showdia', 'mm/dd/yyyy');"  type="image" src="images/cal.gif" align="absmiddle" name="reset" style="cursor:pointer"></div> 
         <div>to:</div>
         <div>  <input type="text" name="showdiafin" id="showdiafin" size="9" value="10/04/2010"><input onclick="return showCalendar('showdiafin', 'mm/dd/yyyy');" type="image" src="images/cal.gif" name="reset" style="cursor:pointer" align="absmiddle"></div>
    
    <div align="center" style="padding:3px;"> <img src="images/language/english/view.g

Can you have control over the names of HTML elements?

  

Hi


I was just wondering, is it possible to have control over the name of an HTML element that's bound to a property of a viewmodel? For example, if I had a viewmodel with a property called ProductDescription, is it possible to have a text input in the view with the name "desc" instead of "ProductDescription" and somehow tell MVC that "desc" binds to ProductDescription?


Not a big issue, but it would be nice to have control over how my HTML elements are named.


Thanks


opaquness of html elements

  

I have a web page with the following css code..


<html>
<head>
<style type="text/css">
div.background
{
  width: 500px;
  height: 250px;
  background: url(klematis.jpg) repeat;
  border: 2px solid black;
}
div.transbox
{
  width: 400px;
  height: 180px;
  margin: 30px 50px;
  background-color: #626469;
  border: 1px solid black;
  filter:alpha(opacity=60);
  opacity:0.6;
}
div.trans
{
  width: 300px;
  height: 135px;
  margin: auto;
  position: relative;
  top: 10%;
  background-color: #ffffff;
  border: 1px solid black;
  filter:alpha(opacity=100);
  opacity:1;
}
div.trans p
{
  margin: 10px 10px;
  font-weight: bold;
  color: #000000;
}
</style>
</head>
<body><div class="background">
<div class="transbox">
<div class="trans">
<p>This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.
</p>
</div>
</div>
</div>
</body>
</html>


Even if the opacity of the "trans" class is set to 1, i was able to see the background image.

Can someone suggest me how to make it completely opaque.

Thanks.


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend