how to set meta tag dynamic from database in mvc - asp.net-mvc-4

ViewData["ChildPageMetaConent"] = lstPageMetaContentChilds; // from this line i get data from database and set to ViewData .
Example : in ViewData["ChildPageMetaConent"] have list class. You can check in Image.
And on Master.cshtml I am accessing ViewData["ChildPageMetaConent"] variable and gointo to write on
page but its print on page like a text .
And on HTMl its look like this :

I got the Answer.
Need to Use #Html.Raw(string)
so it print exact html tag on page.

Related

Selecting element using webdriver (duplicate identifiers)

I have to look at an application which I can't use the normal selectors (like "id", "name", etc - this is a design flaw) but I do have a custom tag which has been applied to elements on the page:
test-tag='x'
and this is fine, I can interact with this using (simple script)
var tag = '[test-tag="x"]';
var selector = $(tag);
However, I have now found that some elements (notably textboxes) have a title and a box element - both have the same custom tag applied. Now the text box is an input type. Anyone know how I can change the above to target specifially input types?
try this:
'input[test-tag="x"]'
for the input box
Take a look at this as well:
https://www.w3schools.com/cssref/css_selectors.asp

Drupal 7 - Print PDF and Panelizer

Hi guys ,
I'm currently working on a Drupal project which use the Panelizer module by overriding the default node display. The panel for this content type is made width a lot of rules and specifications in order to display some specific content (like views) according some fields.
Now I need to print in PDF the same content that is displayed by the panelizer module but in another display (in one column ), so I cloned the display I use and rearranged it to display what I want.Then I want to use this display width the print module but I didn't managed to do that.
Any idea how can I do that ?
I just can't use the default node render, because I would miss some informations dues to the specifications used in the panel, and I can't print the panelized content because it's not the same display.
I read this thread but how can I say to the print module to use the "print" display I cloned instead of the default one ?
Any suggestions or ideas will be appreciated or if you have another idea for doing that you're welcome :)
Thank you !
In your print pdf template you can load the node then create a view with the display and finally render it : drupal_render(node_view(node_load($node->nid), "name of your display")) ;
Another way is to alter node entity info, telling that 'print' view can be panelized, i.e.
/**
* Implements hook_entity_info_alter().
*/
function mymodule_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['print']['custom settings'] = TRUE;
...
}
After that, you go to panelizer settings of your content type(s), and set whatever you want for the print view mode

Yii Retrieve and store in a variable a renderPartial file

I have a php file under protected/views/directory_controller_name with formatting like that
<p>
<?php echo $model->title;?>
</p>
...
I display the file with classic method in the controller :
$this->render('filename',array('model'=>$model));
But know, I need to send an email with the same template/layout so I want to store the render of the file in an variable like
$msgHTML = $this->renderInternal('_items', array('model'=>$model));
But it doesn't work!
How can I get render view from a file and store in a variable?
Is it possible?
I don't want to use:
$msgHTML = '<p>'.$model->title.'</p>'
...
Because the file is very long and I don't want to duplicate code!!!
Don't use the renderInternal method, use renderPartial instead. Render internal is low level method and should not be used in such context. To catch the output just set the $return parameter to true:
<?php $output = $this->renderPartial('_subView', $dataArray, true); ?>
$msgHTML = $this->renderInternal('_items', array('model'=>$model), true);
http://www.yiiframework.com/doc/api/1.1/CBaseController#renderInternal-detail
I might be missing something, but can't you just use regular render() with the return argument set to true? Then you can just use a view 'name' instead of knowing the path. (And unless my trusty stack trace logger is broken, renderFile and renderInternal take the same fully qualified path argument. At least I can see renderPartial() passing the full path to my view file to renderFile.)
you can do this with these ways
1) if you want to get the output with header and footer (i.e ) full layout then do this
//add true in the last parameter if you want a return of the output
$htmloutput=$this->render('_pdfoutput',array('data'=>'nothing'),true);
2) similarly if you don't want to get the layout files just use renderpartial in the same way
$htmloutput=$this->renderpartial('_pdfoutput',array('data'=>'nothing'),true);
you will get the html of files in the variable . use this anywhere

VB.NET hates </script> tag in string literal

I am trying to update some of my projects old login code, which is a bunch of aspx files with inline VB.NET (no codebehind).
The page in question uses a master page layout. I am trying to expose the header of this master page to the slave pages, which I did by adding a placeholder in the header and exposing it as a property of the master page.
The problem comes in when I try to add a script tag to the header, like this:
Master.Header.Controls.Add(New LiteralControl("<script type='text/javascript' src='http://mysite.com/myscript.ashx'></script>"))
Then i get the error "Only Content controls are allowed directly in a content page that contains Content controls."
I think the aspx parser is seeing the </script> in the string literal and thinking that it is then end of the tag, and giving me that error because it thinks the content following that end tag are not in an block. I can add other tags to the header perfectly fine.
What do you think?
You can escape the / in </script> to prevent this.
Master.Header.Controls.Add(New LiteralControl("<script type='text/javascript' src='http://mysite.com/myscript.ashx'><\/script>"))
Alternatively, you can try
Dim gc As New HtmlGenericControl
gc.TagNane = "script"
gc.Attributes.Add("type", "javascript")
gc.Attributes.Add("src", "http://mysite.com/myscript.ashx")
Master.Header.Controls.Add(gc)

How to access values from dynaaction form in jsp

I can set the attributes in the servlet and I can get those values in jsp by accessing the get attribute.
do we have anything to access values in jsp like that.
For Example:
DynaActionForm home = (DynaActionForm) form;
String age = (String)home.get("age");
I want to access this age in jsp.
Please help me solve this.
Thanks
If your struts-config.xml file is configured correctly, all you need to do is use the bean:write tag.
You can add the map of your formbean in the request scope like that:
Map m = dynaform.getMap();
request.setAttribute("mapForm", m);
And then access propertys into your jsp with:
${mapForm['nameOfYourFormProperty'] }
This is using JSTL. Otherwise you can use that:
<%= ((Map)request.getAttribute("mapForm")).get("nameOfYourFormProperty") %>
Are you asking if you can access DynaActionForm values directly within the Struts View (jsp) component?
You could try setting the DynaActionForm as a request attribute in your Struts Action:
DynaActionForm myForm = (DynaActionForm) form;
request.setAttribute("myForm", myForm);
Then in your JSP page import DynaActionForm and do something like:
DynaActionForm myForm = (DynaActionForm) request.getAttribute("myForm");
String age = (String) myForm.get("var");
But it would be much better to just access the value you needed within the Struts Action and just set that value onto the request or session.