web stats analysis

Archive for August, 2013

The type or namespace name ‘SqlConnection’ could not be found (are you missing a using directive or an assembly reference?).

You just add the below namespace:

using System.Data.SqlClient;

The type or namespace name ‘List’ could not be found (are you missing a using directive or an assembly reference?).

You just add the below namespace:

using System.Collections.Generic;

How to passing hidden variables to the contact Form7 in wordpress?

If you want to passing hidden variable to the contact form7 so you can esily do it.click on below image.

See in above image and select appropriate tag whaterver you want.

Now where you add the variable in contact form7?

It also easy.Add the variable into your contact form7 in message body it’s like click on below image.Here I pass the [_post_title]. It’s pass the post title.

Browser back button issue after logout.

Choice:-1: Set Response Cache settings in code-behind file for a page.


// Code disables caching by browser.

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

Choice:-2: Set META tag for HTTP cache settings in your ASPX page header.


<META Http-Equiv="Cache-Control" Content="no-cache"/>
<META Http-Equiv="Pragma" Content="no-cache"/>
<META Http-Equiv="Expires" Content="0"/>

Choice:-3: Clear browser’s history through JavaScript using below script.


//clears browser history and redirects url

<SCRIPT LANGUAGE="javascript">
function ClearHistory()
{
var backlen = history.length;
history.go(-backlen);
window.location.href = loggedOutPageUrl
}
</SCRIPT

Choice:-4: Clear browser’s history through JavaScript injecting through code-behind file via Response.


protected void LogOut()
{
Session.Abandon();
string loggedOutPageUrl = "Logout.aspx";
Response.Write("<script language="'javascript'">");
Response.Write("function ClearHistory()");
Response.Write("{");
Response.Write(" var backlen=history.length;");
Response.Write(" history.go(-backlen);");
Response.Write(" window.location.href='" + loggedOutPageUrl + "'; ");
Response.Write("}");
Response.Write("</script>");
}

How to create dynamically html table in vb.net?

Generate insert statements from a specific table data using SQL Server in asp.net

I have a solution:

Just copy the below script into your asp page.


<script  runat="server">
Sub submit(sender As Object, e As EventArgs)
Dim row,numrows,numcells,j,i
row=0
numrows=cint(rows1.Value)
numcells=cint(cells1.Value)
for j=1 to numrows
Dim r As New HtmlTableRow()
row=row+1
for i=1 to numcells
Dim c As New HtmlTableCell()
c.Controls.Add(New LiteralControl("row " & j & ", cell " & i))
r.Cells.Add(c)
next
t1.Rows.Add(r)
t1.Visible=true
next
End Sub
</script>

Then write the below code into your html page.


<!DOCTYPE html>
<html>
<body>

<form runat="server">
<p>Table rows:
<select id="rows1" runat="server">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br>Table cells:
<select id="cells1" runat="server">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br><br>
<input type="submit" value="Display Table" runat="server" OnServerClick="submit">
</p>
<table id="t1" border="1" runat="server" visible="false"/>
</form>

</body>
</html>

How to get dynamic value in dropdownlist in asp.net?

How to get value of menu type in C# code?

I try and got solution is below:

Just add the below code into your particular page.


public static void dropdownbind1(string strtbl, string field, DropDownList dl, string dttext, string dtvale)
{
dl.Items.Clear();
str = "select distinct " + field + " from " + strtbl + ""
cmd = new MySqlCommand(str, Classmysql.con);
dtp = new MySqlDataAdapter(cmd);
ds = new DataSet();
dtp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
dl.DataSource = ds;
dl.DataTextField = dttext;
dl.DataValueField = dtvale;
dl.DataBind();
dl.Items.Insert(0, "SELECT");
}
else
{
dl.Items.Insert(0, "no details");

}
here is the example.it is general method.

}

Your problem has been solve.

ASP.NET: ListView display Image based on database column being Null or not.

Display images from SQL server database using asp.net.

I try and got solution is below:

Just typed below code in your aspx page:


<ItemTemplate>
<tr style="">
<td>
<asp:Literal ID="lblPic" runat="server" />
...
...
</td>
<td>
<a href="?team=<%# TeamNumber() %>&player=<%# Eval("PlayerKey") %>"><asp:Label ID="PlayerLabel"

runat="server" Text='<%# Eval("Player") %>' /></a>
</td>
<td>
<asp:Label ID="PositionLabel" runat="server" Text='<%# Eval("Position") %>' />
</td>
</tr>
</ItemTemplate>

Just type the below code into your code behind.


Protected Sub ListView1_ItemDataBound(ByVal sender As Object, ByVal e As ListViewItemEventArgs)
If e.Item.ItemType = ListViewItemType.DataItem Then
Dim lblPic As Literal = CType(e.Item.FindControl("lblPic"), Literal)
Dim rowView As System.Data.DataRowView
rowView = CType(e.Item.DataItem, System.Data.DataRowView)

If Convert.IsDbNull(rowView("hasPic") = true then
lblPic.Text = "<img src=\"/Images/sports/never.gif\" alt=\"Picture Available\" CssClass=\"icon right\" />"
Else
lblPic.Text = "<img/> To Display Pic"
End If
End If
End Sub

How to get html controls value in controller?

How to pass value from view to controller?

How to pass textbox value to controller in asp.net mvc?

I have a solution is below:

You just Check below example:

I typed below code in my view



@using (Html.BeginForm("Add", "Student",FormMethod.Post))
{
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
Studemt Name : <input id="studname" id="studname" type="text" />
</td>

</tr>

<tr>
<td>
<input type="submit" name="submit" value="Submit" />
</td>
</tr>

</table>
}

I typed below code in my controller.



[HttpPost]
public ActionResult Add(FormCollection collection)
{
string name = collection.Get("studname");
return View();
}

The type or namespace name ‘RequiredAttribute’ could not be found (are you missing a using directive or an assembly reference?).

The type or namespace name ‘Required’ could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name ‘DisplayAttribute’ could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name ‘Display’ could not be found (are you missing a using directive or an assembly reference?)

I have a solution is below:

You just add below namespace:

using System.ComponentModel.DataAnnotations;

How to bind repeater from two tables in asp.net?

Bind multiple tables to one repeater.

I have a simple solution:

I have two tables Users & Services and my repeater has fields from the two tables.

First create repeater like this.


<asp:Repeater ID="rpServices" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>photo_user</th>
<th>name_user</th>
<th>Service_Name</th>
<th>Field_service</th>
<th>Cost_service</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("photo_user")%></td>
<td><%# Eval("name_user")%></td>
<td><%# Eval("Service_Name")%></td>
<td><%# Eval("Field_service")%></td>
<td><%# Eval("Cost_service")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

Then Create a method for repeater fill up.


private void RepeaterBind()
{
string connectionString = "Data Source=sandeepss-PC;Initial Catalog=CodeFirst;User ID=sa; Password=knowdev";
SqlConnection cn = new SqlConnection(connectionString);
cn.Open();
SqlCommand cmd = new SqlCommand(@"Select u.photo_user,u.name_user,
s.Service_Name,s.Field_service,
s.Cost_service FROM Users as u inner join Services as s on u.userId=s.userId", cn);
IDataReader dr = cmd.ExecuteReader();

DataTable dt = new DataTable();
dt.Load(dr);
rpServices.DataSource = dt;
rpServices.DataBind();

}

Finally Call this method where you filling repeater control.

For example I am calling it on Page_Load.

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RepeaterBind();
            }
        }