Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all 3938 articles
Browse latest View live

Radiobutton not fire an event..

$
0
0
I have a listview control in that i put radiobutton but i can't find when the radio button is clicked..
 
my code is here
 

<asp:ListView ID="ListView2" runat="server" ItemPlaceholderID ="BrandName" OnSelectedIndexChanged="ListView2_SelectedIndexChanged" OnSelectedIndexChanging="ListView2_SelectedIndexChanging" OnItemCommand="ListView2_ItemCommand">
<LayoutTemplate >
<ul>
<asp:PlaceHolder runat ="server" id="BrandName"></asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li><asp:RadioButton ID="rodB1" runat="server" GroupName="G3" OnCheckedChanged="rodB1_CheckedChanged" AutoPostBack="True" /><%#Eval("Brand")%></li>
</ItemTemplate>
</asp:ListView>

Best Practise

$
0
0
Kindly help me,
actually i am learning mvc
so which is best ,like i want to use entity framework with stored procedure ,kindly help

Problems with Profiles ...

$
0
0
I have this code is web.config
<anonymousIdentificationenabled="true"/><profileenabled="true"><properties><addname="FName"type="String"allowAnonymous="true"/></properties></profile><authenticationmode="Windows"/>
 
and this code is default.aspx.cs page
 
Profile.FName = TextBox1.Text;
Response.Write("Your name is: " + Profile.FName);
 
after runing the page, when I enter a data to text and click on button it gives me an error and this is error:
 
this.SetPropertyValue("FName", value);
 
and on the page error is:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
So, please help me to solve this problem.

ASP.Net Best Practices

$
0
0
Hi Friends,
 
I want to know some good books to refer for "ASP.Net best practices" ,I have googled the same and there are so many books available.So can any of you tell me some good book to refer depending upon your reading experiences.
 
Regards

Retry on duplicate keys ex

$
0
0
How can I catch and retry if I got a duplicate keys error?
If InsertProviderMasterCommand failed due to dups go to GenerateKeys
and try again???
Try
    GenerateKeys(myRow)
    If InsertProviderMasterCommand(myRow) = TrueThen
          MasterInsertCount += 1EndIfCatch ex As Exception
     Throw ex
  EndTry

If else structure problem

$
0
0
In if else structure when null arguments are passed to two string variables then it always hit the condition when i have set Var1 != "" && Var2 != "" why ? since nulls are passed to both then why it hits this condition ?
 
code:
 
public ActionResult ShowCalTextBox(String DateFrom, String DateTo)
        {
 
           if (DateFrom != ""&& DateTo == "")
            {
                IEnumerable<GetEmpRec_DateResult> EmpRec_DateFrom = DataContext.GetEmpRec_Date(DateFrom, null).ToList();
                ViewBag.Dates = "Records for"+" "+ DateFrom ;
                return View(EmpRec_DateFrom);
 
            }
            elseif (DateFrom == ""&& DateTo != "")
            {
                IEnumerable<GetEmpRec_DateResult> EmpRec_DateTo = DataContext.GetEmpRec_Date(null, DateTo).ToList();
                ViewBag.Dates = "Records for" + " " + DateTo;
                return View(EmpRec_DateTo);
            }
            elseif (DateFrom != ""&& DateTo != "")
            {
                IEnumerable<GetEmpRec_DateResult> EmpRec_ByDate = DataContext.GetEmpRec_Date(DateFrom, DateTo).ToList();
                ViewBag.Dates = "Records from" + " " + DateFrom +" "+"to"+" "+DateTo;
                return View(EmpRec_ByDate);
            }
            elseif (DateFrom == ""&& DateTo == "")
            {
                IEnumerable<GetEmpRec_DateResult> EmpRec_Default = DataContext.GetEmpRec_Date(null, null).ToList();
                ViewBag.Dates = "No date selection";
                return View(EmpRec_Default);
            }
 
            return View();
        }
it hits this one when i first browse this action or run this action.
 
else if (DateFrom == "" && DateTo != "")

Flash Banner in Mobile asp.net

$
0
0
I tried to change the flash banner text from 50% to 60% and its only show 60% in Desktops not in mobile.
Please let me know if any one have the solution detail and steps of how to fix it :(

How to pass user details from the database - basic auth

$
0
0
Dear all,
 
I am writing to seek help in how do construct function/method which can pass username and password from database in the "userPro" class:
publicclass UserPro : IProvidePrincipal
    {
 
       // private const string Username = "hi";
//private const string Password = "hi";
public IPrincipal CreatePrincipal(string username, string password)
        {
            if (username != Username || password != Password)
            {
                returnnull;
            }
 
            var identity = new GenericIdentity(Username);
 
            IPrincipal principal = new GenericPrincipal(identity, new[] { "admin" });
            return principal;
        } 
 
I manage to create method in data access layer:
 
publicclassUser : iUser
    {
        //private cdwEntities db = new cdwEntities();
private cdwEntities2 db;
        public User(cdwEntities2 ctx)
        {
            db = ctx;
        }
 

        publicbool Login(string UserName, string Password)
        {
            var user = db.api_login.FirstOrDefault(u => u.username == UserName
                     && u.password == Password);
 
            if (user != null)
            {
                if (user.password == Password)
                {
                    returntrue;
                }
            }
 
            returnfalse;
        }
 
    }
 
Can I use login method in userPro class and if so, any guidelines or framework i could use to construct the above method/class.
Thank you for your time and help.

radiobuttonlist change event with javascript

$
0
0
I have 2 RadioButtonList
rdBtnPersonel_Status and rdBtnPersonel_FoodStatus
 
i wrote :
<asp:RadioButtonListrunat="server"ID="rdBtnPersonel_Status"RepeatDirection="Horizontal"Width="100%"DataSourceID="ObjDsPersonelStatuses"onclick="javascript:radioButtonListOnClick('<%#((RadiobuttonList)Container.FindControl("rdBtnPersonel_Status")).ClientID%>');">
 

i want when i click rdBtnPersonel_Status , if the valu eual A the rdBtnPersonel_FoodStatus be disabled. (with javascript)
 
can any body help me?

Question Event does not run when I click image that has event attached to it

$
0
0
Hello Everybody,
 
I would like to know if there is something I am missing why my ASP.NET is not running the script that is embedded in the master page, I imagine that it should be running in any page using the master page (where I have the event embedded) as shown in my screenshot but to my surprise it doesn't run the alert message ..
 
When I click any of the images I am not seeing the alert box that I am expecting as a response to the click event ..
 
My code is shown below .. any help much appreciated .. thanks again:
 
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster"%> 
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en"><headrunat="server"><title></title><linkhref="~/Styles/Site.css"rel="stylesheet"type="text/css"/><scriptsrc="Scripts/jquery-1.4.1.js"type="text/javascript">
    
        $('.main').ready(
             function () {
                 alert('hello');
             });
 
        $('img').click(
             function () {
                 alert('hello from image');
             
             });
 
    </script><scriptsrc="Scripts/myJavascriptTools.js"type="text/javascript"></script><asp:ContentPlaceHolderID="HeadContent"runat="server"></asp:ContentPlaceHolder></head><body> 
 

RDLC Report Designing

$
0
0
Suppose my stored procedure returns multiple datatable then how to manage that datatable in DataSet.xsd file

Telerik grid vs. Kendo grid and Ajax calls

$
0
0
Anybody familiar with Telerik's grid products...
 
We had code that previously implemented the telerik grid
 
@(Html.Telerik().Grid()<myTransactions>
    .Name("Transactions")
        .ClientEvents(events => events.OnLoad("TransactionsGrid_onLoad"))
        .ClientEvents(events => events.OnDataBound("TransactionsGrid_onDataBound"))
    .DataBinding(dataBinding => dataBinding
        .Ajax()
        .OperationMode(GridOperationMode.Client)
        .Select("TransactionsAjax", controller))
 
We have recently migrated to Telerik's Kendo grid, and changed the code to the following:
 
@(Html.Kendo().Grid<myTransactions>()
    .Name("Transactions")
    .AutoBind(true)
    .Events(events => events.DataBound("TransactionsGrid_onDataBound"))
        .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
        .Read(read => read.Action("TransactionsAjax", controller))
        .PageSize(15))
 
In addition to the grid, the page has 3 other fields; a combobox and 2 date fields that filter the grid. The filtering works fine.
 
However, the printer friendly button calls TransactionsAjax for the Kendo grid and removes all filtering that was applied. The original Telerik just rendered the existing grid as print friendly without making a redundant call to TransactionsAjax.
 
Since the desired data to be printed is already filtered and available on the screen there is no reason to repeat the call. Is there some grid configuration setting I am missing that would stop the undesired call from happening?

ASP.NET MVC Web API - filter query with pagesize

$
0
0
Hello,
 
If I search (api/test/cusip=00089PAA6&isin=555), I should get five records of cusip = 00089PAA6 and other five for isin = 555 in descending order (2014), but instead i only get results from cusip parameters (00089PAA6) and nothing from isin and they are also not in a descending order.
 
This is what I have so far:
public HttpResponseMessage Get([FromUri] Query query)
        {
            var data = db.database.AsQueryable();
 
            int pageSize = 10;
 
            if (query.price_type != null)
            {
                data = data.Where(c => c.Cover == query.price_type);
            }
 
            var filteredData = new List<IQueryable<database_BWICs>>();
 
            if (!string.IsNullOrEmpty(query.isin))
            {
                var ids = query.isin.Split(',');
                foreach (string i in ids)
                {
                    filteredData.Add(data.Where(c => c.ISINs != null&& c.ISINs.Contains(i)));
                }
            }
 
            if (!string.IsNullOrEmpty(query.cusip))
            {
                var ids = query.cusip.Split(',');
                foreach (string i in ids)
                {
                    filteredData.Add(data.Where(c => c.CUSIP != null&& c.CUSIP.Contains(i)));
                }
            }
 

 
            if (filteredData.Count != 0)
            {
                data = filteredData.Aggregate(Queryable.Union);
            }
 
            int total = data.Count();
            if (!data.Any())
            {
                var message = string.Format("No data was found");
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
            }
 
            if (query.cusip != null)
            {
                data = data.OrderByDescending(c => c.CUSIP == query.cusip).Take(pageSize);
            }
            if (query.isin != null)
            {
                data = data.OrderByDescending(c => c.ISINs == query.isin).Take(pageSize);
            }
            
 
            //return Request.CreateResponse(HttpStatusCode.OK, data);
return Request.CreateResponse(HttpStatusCode.OK, new { total, data });
        }
Am I missing somthing? if so, is their a better way to do this? Thanks in advance for your help and time.

Built in authentication

$
0
0
Hi! I'm teaching some basic ASP.NET.
 
I have looked at a solution for login-page.
 
There is the built in forms-authentication but I seem to work bad.
 
Login works sometimes and sometimes not. Doesn't seem so stable or maybe I am doing something wrong.
 
Is this something you would use on a live site?
 
What else should you use?

Asp.net

$
0
0
I have a textbox for quantity,Label drop downlist for different Products.I have a Place holder. and a a ok button. if i give a value of quantity 3 and selct a product suppose mouse the 3 labels with name mouse with 3 text boxes appearing. My problem is i have to display the mouses as mouse1 mouse2 mouse3.how will i do please help.
My code is
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
for (int i = 0; i < Convert.ToInt16(TextBox1.Text); i++)
{
Label la = new Label();
la.Text = DropDownList1.SelectedItem.Value;
la.ID = "abc" + i.ToString();

PlaceHolder1.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;


TextBox tb1 = new TextBox();
tb1.ID = "ghj" + i.ToString();
PlaceHolder1.Controls.Add(tb1);
PlaceHolder1.Controls.Add(new LiteralControl("
"));

}
}
}

how to convert image into text

$
0
0
Hi!
can someone provide solution for converting image into text
in asp.net?
 
Thanks
Hidayat Ali

how to bind image from database to image control in asp.net

$
0
0
hi there anyone can help me ....
 
i have created a database in which i am saving the id[int],name[varchar],visPic[image]
 
and i have created a search page for the visitor search by id and after searching griedview is visible for the data of visitor and when we click get details in gried view next page will open by auto fill id number, name , and pic in respective control. But i cannot bind the image in image control.Please help me out somebody i will be vry thnkful .....

How to tie a gridview row edit properly

$
0
0
I have a Gridview that has many pages. I order it by an ID number in descending order which is displayed. When I try to edit the row with my image button, the index I get does not match the row I clicked Edit on. How do I tie the row I clicked Edit on to the index the gvRowEditing method recieves? It gets a GridViewEditEventArgs object but that does not have a Command Argument that can tie the row to.
 
Thanks!

inserting data in mysql database using c#

$
0
0
Hi
I wanted to insert my form into mysql database
Below is the code i used
 
protected void Submit_Click(object sender, EventArgs e)
{
MySqlConnection connection = null;
if(RadioButton1.Checked==true)
{
lblgender.Text= RadioButton1.Text;
}
else
{
lblgender.Text= RadioButton2.Text;
}
lblbusinessCat.Text=DropDownList1.SelectedValue;
using (connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString))
{
try
{
string sql = "INSERT INTO login(Username, Gender, Email, MobileNo, Category_Id, CompanyArea, CompanyName, CompanyNo, AltCompanyNo, Address)VALUES ('@Username', '@Gender', '@Email', '@MobileNo', '@Category_Id', '@CompanyArea', '@CompanyName', '@CompanyNo', '@AltCompanyNo', '@Address') ";

MySqlCommand cmd = new MySqlCommand(sql);

cmd.Parameters.AddWithValue("@Username", txtUserName.Text.Trim());
cmd.Parameters.AddWithValue("@Gender", lblgender.Text.Trim());
cmd.Parameters.AddWithValue("@Email", txtEmailId.Text.Trim());
cmd.Parameters.AddWithValue("@MobileNo", txtmobile.Text.Trim());
cmd.Parameters.AddWithValue("@Category_Id", lblbusinessCat.Text.Trim());
cmd.Parameters.AddWithValue("@CompanyArea", txtCompanyLoc.Text.Trim());
cmd.Parameters.AddWithValue("@CompanyName", txtCompanyname.Text.Trim());
cmd.Parameters.AddWithValue("@CompanyNo", txtCompNo.Text.Trim());
cmd.Parameters.AddWithValue("@AltCompanyNo", txtCompaltNo.Text.Trim());
cmd.Parameters.AddWithValue("@Address", txtCompAddress.Text.Trim());

cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();



Session["username"] = txtUserName.Text;
Response.Redirect("Business_NewUpload.aspx", false);
//lblError.Text = "Data Saved";
}
catch (Exception ex)
{
Response.Write("An error occured: " + ex.Message);
//lblError.Text = ex.Message;
Response.Redirect("BusinessMoney_About.aspx", false);
}
finally
{
if (connection != null)
{
connection.Close(); //close the connection
}
}
}
 
}
 

i dont get any error , but my values are getting stored as @username,@gender
 
Please anyone help me.....It is very urgent for me to correct this

How can Create this table in sql

$
0
0
Whats the sql query for this table
the fields are : table name=Emp ,date_join current systemdate,
                                          sal,city,state
 
pabitra behera
Viewing all 3938 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>