vuyiswamb 17 Posting Whiz

Good Day All

I have another question. I have a Silverlight application and in one of the Silverlight pages i am hosting an Asp.net Page using a RadhtmlContainer(Telerik). I created a Cookie in Silverlight like this

public static void SetCookie(string key, string value)
        {

           // string oldCookie = HtmlPage.Document.GetProperty("cookie") as String;
            DateTime expiration = DateTime.UtcNow + TimeSpan.FromDays(2000);
            string cookie = String.Format("{0}={1};expires={2}", key, value, expiration.ToString("R"));
            HtmlPage.Document.SetProperty("cookie", cookie);
        }

and i have the same generic function to access it like this

public static string GetCookie(string key)
        {
            string[] cookies = HtmlPage.Document.Cookies.Split(';');
            key += '=';
            foreach (string cookie in cookies)
            {
                string cookieStr = cookie.Trim();
                if (cookieStr.StartsWith(key, StringComparison.OrdinalIgnoreCase))
                {
                    string[] vals = cookieStr.Split('=');

                    if (vals.Length >= 2)
                    {
                        return vals[1];
                    }

                    return string.Empty;
                }
            }

            return null;
        }

so i am trying to access this cookie in an asp.net page that is hosted on the the html Container , but i dont find the cookie.

Basically what i want to Achieve is

i want to access a value that is being created in Silverlight e.g "userid" "Username" normally i store it in the Cookie , so now i want to do a database insert , i need to do that insert from that asp.net page, but i cant get hold of that cookie value.

Thanks

vuyiswamb 17 Posting Whiz

Good Day All

i am having a strange error here. I am using Silverlight and i am accessing an Asp.net page inside a RadHtmlContainer. i am doing an Insert that will insert only two records and i am calling a Service that i tested independently with a wcftest client and it work , now i am doing in my Silverlight app and i get the Following error

This factory buffers messages, so the message sizes must be in the range of an integer value.
Parameter name: bindingElement.MaxReceivedMessageSize

i googled a bit and a lot of people said it was timing out and i look at the Service from the DAL -->BLL -->PL , i made sure that the web config looks like this

<basicHttpBinding>
        <binding name="BasicHttpBinding_ILogger" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>

and still i get the same error, i am not doing anything funny in my insert in the DAL it only does something like this

sp_Credit_Tuckshop   @USERID ,@SCHOOLID ,@AMOUNT

and that's all what is the Problem


Thanks

vuyiswamb 17 Posting Whiz

Good Dal All

i have this aspx page

<%@ Page Language="C#" Async="true" Trace="true" 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 runat="server">
    <title></title>
</head>
<body> 
    <form runat="server" method="post"  action="https://www.vcs.co.za/vvonline/ccform.asp" >
    <asp:HiddenField ID="p1" Value="4635" runat="server" />
    <asp:HiddenField ID="p2" Value="2" runat="server" />
    <asp:HiddenField ID="p3" Value="Some Goods" runat="server" />
    <asp:HiddenField ID="p4" Value="5.00" runat="server" />
    <asp:Button ID="btnSubmit" runat="server" Text="Pay by Credit Card" 
       />
    </form>
</body>
</html>

what happens here is that on the Client side when someone clicks the Button it will do the payment and redirect to the page, i want to do this one the server side. i tried this

protected void btnSubmit_Click1(object sender, EventArgs e)
    {

        string P1 =  p1.Value;
            
        string P2 = p2.Value;

        string P3 = p3.Value;

        String URl = "https://www.vcs.co.za/vvonline/ccform.asp?p1=" + P1 + "&p2=" + P2 + "&p3=" + P3;
        WebClient svc = new WebClient();
        svc.UploadStringAsync(new Uri(""), "Post", "AT");
        svc.UploadStringCompleted += new UploadStringCompletedEventHandler(svc_UploadStringCompleted);
        
       
    }

and

void svc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
    {
        String estr = e.Result;
    }

You can test using that URL

Thanks

vuyiswamb 17 Posting Whiz

I see a lot of people have been asking this question, some was because of the if postback check , but mine is different. i am using AjaxModalExtender to show my popup on the server side. this is my markup

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="PopTester.TestPage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!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 runat="server">
<style type="text/css">

 .modalBackground
{     background-color: Yellow;
      filter: alpha(opacity=60);
      opacity: 0.6;
}

   </style>

 
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager>

    <asp:Panel ID="Panel1" runat="server">

    <asp:Button ID="Button1" runat="server"

    Text="CreateModal" OnClick="Button1_Click" />

    </asp:Panel>


         <asp:Panel ID="ModalPanel" runat="server" Style="display: none" HorizontalAlign="Center" BackColor="Green">
             <div>
     <asp:UpdatePanel ID="Update" runat="server">
     <ContentTemplate>
        <asp:GridView ID="GridView1"  AutoGenerateColumns="false" runat="server" Height="176px" Width="453px">
        <Columns>
        <asp:TemplateField HeaderText="ID">
        <ItemTemplate>
        <asp:CheckBox ID="chkId" runat="server" />
        <asp:Label ID="lblId" runat="server" Text='<%#Eval("ID")%>'></asp:Label>
        </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Name">
        <ItemTemplate>
        <asp:Label ID="lblname" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
        </ItemTemplate>
        </asp:TemplateField>

        
        <asp:TemplateField HeaderText="Lastname">
        <ItemTemplate>
        <asp:Label ID="lblLastname" runat="server" Text='<%#Eval("Lastname") %>'></asp:Label>
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>

        </asp:GridView>

             <asp:Button ID="btnPickrecord" runat="server" Text="Pick Record" 
             onclick="btnPickrecord_Click "   />
    <asp:Button ID="btnload" runat="server" onclick="btnload_Click"  
        Text="Load Data" />
                </ContentTemplate>
     </asp:UpdatePanel>
     
        </div>
        <asp:Button ID="btnCancel" runat="server" Text="Close Me" 
                 onclick="btnCancel_Click" />
    </asp:Panel>
        <asp:TextBox ID="txtreference" runat="server" AutoPostBack="True"></asp:TextBox>
        <p>
            &nbsp;</p>
    </form>
</body>
</html>

as you can see i have a gridview that will be on the modal and its working fine, now after the grid has returned some results, i will select one record via the checkbox on the Grid and click the button "btnPickrecord" and this will fire my server side code

protected void btnPickrecord_Click(object sender, EventArgs e)
        { 
                 foreach (GridViewRow dataItem …
vuyiswamb 17 Posting Whiz

i understand that, but what Error are you getting ?

vuyiswamb 17 Posting Whiz

What Error do you get when you run your code ?

vuyiswamb 17 Posting Whiz

ok if i undersstand you correctly , you want to show the users based on the selected user on the Dropdownlist, if so ,
1) You dont look like you filter your results
2) Does your Dropdownlist show data ? if so , you still need to set te DataValueField so that you can use that value to populate or Filter the grid Data
3) I see your commented come, it seemed like you wanted to retrieve the value of the selected dropdown, its not the correct attempt that you did, to get the value do something like

String MyVal = DropDownList1.SelectedValue;

this will be automatically casted to string, so you dont need the to string cast

Please be clear.

vuyiswamb 17 Posting Whiz

Run this Script

USE MyDatabasename
        GO
        sp_configure 'allow updates', 1
        GO
        RECONFIGURE WITH OVERRIDE
        GO 
   
        sp_resetstatus 'MyDatabasename'
        GO

        sp_configure 'allow updates', 0
        GO
        RECONFIGURE WITH OVERRIDE
        GO
vuyiswamb 17 Posting Whiz

But making a listBox.Item.Add would add the item from listbox1 to the listbox2 right?
Yes

here is my Example

<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" 
        onselectedindexchanged="ListBox1_SelectedIndexChanged">
        <asp:ListItem>Food</asp:ListItem>
        <asp:ListItem>Vegetable</asp:ListItem>
        <asp:ListItem>Meat</asp:ListItem>
    </asp:ListBox>
    <asp:ListBox ID="ListBox2" runat="server" AutoPostBack="True"></asp:ListBox>

and on the Server side

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           

        }

        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox2.Items.Add(ListBox1.SelectedValue);
        }
    }
}
vuyiswamb 17 Posting Whiz

ok tell me , you dont see your Database or it shows but with a Red "Arrow" Pointing Down

vuyiswamb 17 Posting Whiz

Does your code return any Errors ?

vuyiswamb 17 Posting Whiz

ok, i am a C# man, but you can easly Convert the code.

first , in the first listbox you dont need to check every item. in the ListBox1_SelectedIndexChanged you must have only one line, this line will add the item in the second listbox like this

ListBox2.Item.add(ListBox1.selectedItem);

this is just an example code, i did not copy form Vs, this is to show you how you could do it.

Regards

Vuyiswa Maseko

vuyiswamb 17 Posting Whiz

You question is very broad. I think every control in your VS , play an important role in different types of Application. i think you should buy a book, it is not easy to answer your question.

vuyiswamb 17 Posting Whiz

You are using too much Wizards that is why your code confuses you. Look at what Sheo did in his article

http://www.dotnetfunda.com/articles/article18.aspx

vuyiswamb 17 Posting Whiz

use OLEDB

vuyiswamb 17 Posting Whiz

i can access it, use another computer and see if you can see it.

vuyiswamb 17 Posting Whiz

:) You are Welcome

vuyiswamb 17 Posting Whiz

You need to Download an offline Installer. It is good because it is an Iso , so you will have everything that you need. But if you download and install from the Internet , you might lose connection and some files that are needed to install Vs might not be downloaded as in your case.

http://www.microsoft.com/express/Downloads/Download-2010.aspx

Look for ISO

vuyiswamb 17 Posting Whiz

First of all what you need to do, when the User logs in, Carry the Username in the Session variable like this


//if the user is Successfully logged in

Session["Username"]  = txtusername.text;

and in all your other pages , you will probably have a Label that will Display the name of the User who is currently logged in , you would get the value from the Session like this

lblUser.Text   = Session["Username"].Tostring();

And when your user logout of your Session then you need to abandon the session or set it to null

Session["Username"] = null

Hope this Helps


Regards

Vuyiswa Maseko

vuyiswamb 17 Posting Whiz

lol what is your doubt ?

vuyiswamb 17 Posting Whiz

Wrap your Controls in an Update-panel the flickering will go away as i did here

http://www.dotnetfunda.com/articles/article732-how-to-create-ficker-free-pages-aspnet-ajax-.aspx

vuyiswamb 17 Posting Whiz

what is the problem ?

vuyiswamb 17 Posting Whiz

Your Site is not Developed with asp.net, i see you used Flash

vuyiswamb 17 Posting Whiz

Well i am not a fan of Linq to SQL, i still prefare SQL Server to do the work on an Engine that stil stays in my DB. but to Answer your question.

In SQL this would be enough

SELECT COUNT(IDComment) 
from  Comment c 
inner join Topic t 
on c.IDTOPIC   = idTopic

So you wont need a where Clause because the Inner join does that for you.

Regards

Vuyiswa Maseko

vuyiswamb 17 Posting Whiz

I have written an article a long time ago about that

http://www.dotnetfunda.com/articles/article781-how-to-consume-third-party-webservice-in-aspnet-.aspx

Look at it. It shows how i consumed it in asp.net

Hope it helps

Vuyiswa Maseko

vuyiswamb 17 Posting Whiz

Good Day All i have a a WCF service , that is checking the login details and its working fine as it should, i decided to add another Function that will display data.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace DAL
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IsDAL" in both code and config file together.
    [ServiceContract]
    public interface IDAL
    {
        [OperationContract]
        int ValidateLogin(String Username, String Password);

        [OperationContract]
        List<LoginModel> GetLogins(); 
    }
}

And the Main class looks like this 

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Configuration;
using System.ComponentModel;

namespace DAL
{
    public class DAL:IDAL
    {
        String strCon = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;

        SqlCommand cmdselect;

        SqlConnection con;

        SqlDataAdapter da;

        /// <summary>
        /// Validate Logins and Return a Integer, if the Value is greater 
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public int ValidateLogin(String Username, String Password)
        {

            con = new SqlConnection(strCon);

            cmdselect = new SqlCommand();

            cmdselect.CommandText = "usp_CheckLogin";

            cmdselect.CommandType = CommandType.StoredProcedure;

            cmdselect.Connection = con;

            cmdselect.Parameters.Add("@USER_ID", SqlDbType.VarChar, 50).Value = Username;

            cmdselect.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = Password;

            cmdselect.Parameters.Add("@Count", SqlDbType.Int);

            cmdselect.Parameters["@Count"].Direction = ParameterDirection.Output;

            int iExistance = 0;

            try
            {
                con.Open();

                cmdselect.ExecuteNonQuery();

                iExistance = (int)cmdselect.Parameters["@Count"].Value;

            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }

            return iExistance;
        }

        /// <summary>
        /// return Logins in a List formart
        /// </summary>
        /// <returns></returns>
        
        public List<LoginModel> GetLogins()
        {
            SqlConnection con = new SqlConnection("User id=motovate;Password=motovate;Server=devsql1;Database=MOTOVATE_PRO_DEV");

            SqlCommand cmdselect = new SqlCommand("usp_SelectLogins");

            cmdselect.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da …
vuyiswamb 17 Posting Whiz

What you need is called "LDAP" You can have many application and query the active Directory

vuyiswamb 17 Posting Whiz

Good Day All

I have a web Method defined like this

[System.Web.Services.WebMethod]
		public static bool CheckSessionExpiration()
		{
			System.Web.HttpContext.Current.Session["CurrentLoginUser"] = null; //This is for Testing Purpose


			if (UserSecurity.GetLoggedInUser() == null)
			{
				return false;
			}
			else
			{
				return true;
			}
 
			 
		}

and in Jquery i have a function that calls this


function ProcessAction() {

PageMethods.CheckSessionExpiration(OnCheckSessionExpirationComplete, OnCallError);

    if (IsLogin == true) {
        alert("Inside the Function");
        var txtNote = $("[id$=txtNote]").val();
        var txtIdentNo = $("[id$=txtIdentNo]").val();
        var sIdentNo = "";

        DisableControls();
        CleanIdentNoList();
        if (ValidFields()) {
            //Get Subscriber Detail
            gAction = $("[id$=cmbAction]").val();
            gNote = txtNote;
            sIdentNo = jQuery.trim(txtIdentNo);
            gMSISDNList = sIdentNo.split("\n");
            gMSISDNIndex = -1;

            ProcessNextItem();
        }
        else {
            EnableControls();
        }
    }
    else {
        window.location = "Login.aspx";
    }

}

and i have a Callback function defined like this

function OnCheckSessionExpirationComplete(result,methodName) {
    if (result == false) {
        
        IsLogin = false;
    }
    else {

        IsLogin = true;
    }

}

Now the "IsLogin" variable is a Global variable defined like this

var IsLogin = true;

What i want to do is to redirect the user if the Session is null, as you can see i have added the line

System.Web.HttpContext.Current.Session["CurrentLoginUser"] = null; //This is for Testing Purpose

For testing Purpose , but my problem is is that, even if its null, the

alert("Inside the Function");

is fired, what i am i doing wrong.

THanks

vuyiswamb 17 Posting Whiz

no leave it empty as i provided in the article what you need to change its only the username and password of Gmail

vuyiswamb 17 Posting Whiz

make sure that you leave the code as is , just provide your username and password it will work

System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
vuyiswamb 17 Posting Whiz

Here is a Simple Example that you can use to send an email to Gmail , if you want to send from hotmail or yahoo , just change the port and the Smtp

http://www.dotnetfunda.com/articles/article747-how-to-send-an-email-using-gmail-in-aspnet-.aspx

vuyiswamb 17 Posting Whiz

What Template do you have ? Is it a website Template ?

vuyiswamb 17 Posting Whiz

If you are writing a .NEt Application even if its in java or C++ , you don't need to install Oracle on the clients machine. The Oracle should be on the Server and should be accessed by your clients application from there. I have never written any apps that target Oracle, but i know its the same way we do with SQL , the only difference is the connection string.

vuyiswamb 17 Posting Whiz

I am not Sure if it is possible to add controls in a Windows Service.

vuyiswamb 17 Posting Whiz

its supposed to be

Response.Write("<script>alert('hello');</script>")
vuyiswamb 17 Posting Whiz

I am not sure what you are doing there, What is the purpose of your code ?

vuyiswamb 17 Posting Whiz

You do not need to store values, What you need to do is to wrap your controls inside an Update Panel and you will get a partial update. and your values will be retained.

vuyiswamb 17 Posting Whiz

Good Day All

I have 20 Textboxes and when there are duplicates in those textboxes , i store them in a List<string> and on fly i build a CheckBoxList and display that as a modal and in that i have a close button to allow the user to correct the duplicate item. My Function is working and it is defined like this

private void ShowAjaxModalDynamic(List<string> lstItems, String Message)
		{
	
          CheckBoxList lstchecks = new CheckBoxList();

					for (int i = 0; i < lstItems.Count; i++)
          {
						lstchecks.Items.Add("Unit" + lstItems[i]);
          }
                 
          AjaxControlToolkit.ModalPopupExtender modalPop = new AjaxControlToolkit.ModalPopupExtender();
          modalPop.ID = "popUp";
          modalPop.PopupControlID = "ModalPanel"; //The Panel must exist on the markup
					modalPop.TargetControlID = "btnComplete"; //the Button must exist on the markup
          modalPop.DropShadow = true;
					modalPop.CancelControlID = "btnCancel"; //The Button must exist on the markup
          modalPop.BackgroundCssClass = "modalBackground";
          this.Panel1.Controls.Add(modalPop);
          this.ModalPanel.Controls.Add(lstchecks);
					lblPanelMessage.Text = Message;
					modalPop.Show();

		}

as you can see i will pass the List and the Message to be displayed. Now this is working Perfect.

My Problem is that when the user clicks the close Button to correct the duplicate in those textbox, and re-click the button that will check for Duplicate , the Modal comes back again even if the duplicate has been removed and the break point to the start part that does the validation does not get fired.


I have attached the Example Project , it is a .net 4 web project


Example Project

www.vuyiswamaseko.com/ExampleProblem/ExampleProblem.zip

vuyiswamb 17 Posting Whiz

it is not always recomended to use win auth, you need to create a user in sql for your app.

vuyiswamb 17 Posting Whiz

Welcome :)

vuyiswamb 17 Posting Whiz

Yes , you must use the Correct index , the "i" and the cell must be match the grid

vuyiswamb 17 Posting Whiz

then you need something like this

GridView1.Rows[i].Cells[5].Text = year;

your i will be your row index

vuyiswamb 17 Posting Whiz

What is the Error ? Do you use the "Button1" to redirect ?

vuyiswamb 17 Posting Whiz

I dont understand your Questiion

vuyiswamb 17 Posting Whiz

The Control that you are using to Navigate with must have a property "Causesvalidation" e.g if you click a Button to move to another page, the there is a Property in a button named "Causesvalidation". set it to false and it will work.

vuyiswamb 17 Posting Whiz

In ASp.NEt we dont use Frames anymore, if you are talking about Consistant look , you must use Master pages, please google for "master pages in asp.net"

vuyiswamb 17 Posting Whiz

is your Function a Public function ? if you created a function , you need to build your BLL and if the PL does not see the function, remove the refence to the Bll and add it again.

vuyiswamb 17 Posting Whiz

Looking at your Problem. In my article i showed an Example. If you create a Class(BLL) or DAL you must add references for the class so that your application can use it. The BLL must never access the Database or execute the Database directly. What you need to do is to add a Reference of our DAL in your BLL and add a Reference of your BLL in your PL(Presentation Layer) your web app, and then you can create an object of a Class and be able to call the functions declared as public in that Method.

vuyiswamb 17 Posting Whiz

1) Let me See an example of your web config ?

2) Can you logon to the server , using SQL manament studio and see if you can connect , to test this use the credentials you provided in the web config.

vuyiswamb 17 Posting Whiz