Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Solution:The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?)

Wednesday

How to fix - The type or namespace name 'SqlConnection' could not be found - error in asp.net?:
                                                         "The type or namespace name ' SqlConnection ' could not be found (are you missing a using directive or an assembly reference?)" error means you just missed to add appropriate namespace for connect your sql database. To fix this issue you just add  the following  namespace in your page top.

            using System.Data.SqlClient;

ASP.NET: How to Show/ Hide Div Tags based on radio button selection

Show/hide div based on radio button selection in asp.net:
                                                                       This post will show you how to create a hidden Div and display it with the click of a link. The following code will Show / Hide a div tags  when changing the selection of a radio button.

Sample code for show/hide div tag from code-behind using asp.net:

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Hide div</title>

    <script runat="server">
        protected void rbtnHideDiv_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (rbtnHideDiv.SelectedItem.Text == "Red")
            {
                divRed.Style.Add("display", "none");
                divGreen.Style.Add("display", "inline");
            }
            if (rbtnHideDiv.SelectedItem.Text == "Green")
            {
                divGreen.Style.Add("display", "none");
                divRed.Style.Add("display", "inline");
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:RadioButtonList ID="rbtnHideDiv" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rbtnHideDiv_SelectedIndexChanged">
            <asp:ListItem>Red</asp:ListItem>
            <asp:ListItem>Green</asp:ListItem>
        </asp:RadioButtonList>
    </div>
    <div style="background-color: Red" id="divRed" runat="server">
        <asp:Label ID="lblTextRed" SkinID="label_information" Text="My background is RED"
            ForeColor="White" runat="server"></asp:Label>
    </div>
    <div style="background-color: Green" id="divGreen" runat="server">
        <asp:Label ID="lblGreen" SkinID="label_information" Text="My background is GREEN"
            ForeColor="White" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

                                   

Sample code for show/hide div tag using java script in asp.net:

<html>
<head runat="server">
    <title></title>
     <script type="text/javascript" language="javascript">

         function hideDiv() {
             document.getElementById('div1').style.display = 'none';
             document.getElementById('div2').style.display = 'none';

             if (document.getElementById('rbtnMain_0') != null) {
                 if (document.getElementById('rbtnMain_0').checked) {
                     document.getElementById('div1').style.display = 'block';
                 }
             }

             if (document.getElementById('rbtnMain_1') != null) {
                 if (document.getElementById('rbtnMain_1').checked) {

                     document.getElementById('div2').style.display = 'block';

                 }
             }
         }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:RadioButtonList ID="rbtnMain" runat="server" onchange="hideDiv()">
            <asp:ListItem Text="rb1" Value="1" Selected="True"></asp:ListItem>
            <asp:ListItem Text="rb2" Value="2"></asp:ListItem>
        </asp:RadioButtonList>
        <div id="divmain">
        <div id="div1">
           div1 <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
        <div id="div2" style="display:none">
           div2  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </div>
        </div>
        
    </div>
    </form>
</body>
</html>
If this post was help to you. Then Share this to your friends. Thanks!

Solution-iphone - UIImagePickerController memory warning("Received memory warning")

Friday

Iphone crash report - Low Memory Warning:  while using UIImagePickerController :
                                                                                              In one of my Iphone project I've  a UIImagePickerController as a synthesized property of my view controller. In general it works fine  for taking/picking photos.  If  I choose/take photos continuously  then I received a memory warning and  the UIImageView become empty(without image).  Some times the app was automatically closed.  I have tried to setting self.imageView.image = nil in viewDidUnload but I got the same "Received memory warning" message. Finally I got the following solution from web.
                   The  solution for UIImagePickerController memory warning is the imagePicker/imageView  wasn't being set to nil in viewDidUnload, but  it needed to remove/dismiss it in didReceiveMemoryWarning method.



Issue:

Solution:
-(void)didreceivememorywarning {
// Release anything that's not essential, such as cached data (meaning //instance variables, and what else...?)

self.imageView.image = nil;

// Releases the view if it doesn't have a superview
[super didReceiveMemoryWarning];

}

                      


 
 
 

RECENT POSTS

Boost

 
Blogger Widgets