Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Saturday, March 31, 2012

table1_onclick generated without javascript function

Hi,

I have a website in dotnet2.0 with a masterpage.

Here is my code of page wich use the masterpage :

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" CodeFile="WfSelectExp.aspx.vb" Inherits="WebForm_WfSelectExp" MasterPageFile="~/MasterPage.master" Title="Appolo" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %><asp:Content ID="ContentSelectBL" ContentPlaceHolderID="ContentPlaceHolderCentral" runat="Server"> <table border="0" cellpadding="0" cellspacing="0" class="TABLE" width="100%"> <tr> <td colspan="2" style="height: 10px; width: 5px;"></td> </tr> <tr> <td style="width: 5px;"></td> <td align="center"> <table id="Table" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td><!-- table presentation -->

And IIS will generated a page with the following code :

 <table id="TABLE1" border="0" cellpadding="0" cellspacing="0" class="TABLE" onload="javascript:CloseFenAttente()" style="height: 87%" width="100%" onclick="return TABLE1_onclick()"> <tr> <td colspan="5" style="height: 5px; width: 5px;"> <input type="hidden" name="ctl00$ContentPlaceHolderCentral$HiddenFieldPoidsTotal" id="ctl00_ContentPlaceHolderCentral_HiddenFieldPoidsTotal" value="0" /> <input type="hidden" name="ctl00$ContentPlaceHolderCentral$HiddenFieldQuantCommPAL" id="ctl00_ContentPlaceHolderCentral_HiddenFieldQuantCommPAL" value="0" /> <input type="hidden" name="ctl00$ContentPlaceHolderCentral$HiddenFieldQuantExpPAL" id="ctl00_ContentPlaceHolderCentral_HiddenFieldQuantExpPAL" value="0" /> <input type="hidden" name="ctl00$ContentPlaceHolderCentral$HiddenFieldQuantCommUL" id="ctl00_ContentPlaceHolderCentral_HiddenFieldQuantCommUL" value="0" /> <input type="hidden" name="ctl00$ContentPlaceHolderCentral$HiddenFieldQuantExpUL" id="ctl00_ContentPlaceHolderCentral_HiddenFieldQuantExpUL" value="0" /> <input type="hidden" name="ctl00$ContentPlaceHolderCentral$HiddenFieldRetour" id="ctl00_ContentPlaceHolderCentral_HiddenFieldRetour" value="0" /> </td> </tr> <tr> <td style="width: 10px; height: 59px;"></td> <td align="center" colspan="3" style="height: 59px"><!-- Table presentation -->

And as you can see you have a Table1.onclick() whereas no function is create before.

I have a lot of code around so I can not post all the page else I have to post all the website..

But it seems to be a bug in dotnet 2.0

I have search on google and found few people with the same issue, someone know more about this?

Or have a solution to this?

thanks,

I have the same problem.....

need help!!!!!!! AJAX applications are useless if very time it raises an error,isn't it?

Saturday, March 24, 2012

Tabstrip OnSelectedIndexChanged

Hi,

I've spent a few hours on tabstrip, and I still don't understand why the tabstrip doesn't trigger the function when I change the tab. Can you help me please
Here's my codes;

Sub Do_Something(sender As Object, e As EventArgs)
...
End Sub

<IE:TABSTRIP id="tab2_2" runat="server" OnSelectedIndexChanged="Do_Something"
And nothing happens when I change the tab, though I implement a lot of actions in the function "Get_Something"
Please help. ThanksAutoPostBack=true?
ya, I forgot to set AutoPostBack="true".

It works great if I use it without the PageView.
But if I use OnSelectedIndexChange and ViewPage at same time, then the function linking to OnSelectedIndexChange is not called at all.

Ex: Now, I add a view page to it.
<IE:TABSTRIP id="tab2_2" runat="server" OnSelectedIndexChanged="Do_Something" targetID="view1"
Then the function "do_something" is not called at all, though it correctly displays the view1

So, anyone has an idea to fix that ? So the function is called when we change the tab.
Thank you

Thursday, March 22, 2012

Take labels name ??

( aspx + vb )
hi everyone !
I really need make that function work !
im brazilian , and i want to make a multilanguage system ,
that function above must look at all ASPX take the labels
ID and send as a parameter
,... so Please , help me ,.. cause it doest work !

'------------------
-----
' LOAD PAGE
'------------------
-----
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
TraduzLbl(me)

end sub

Sub TraduzLbl(byval parent As Control)
Dim XmlLang1 as new XmlLang
Dim varxml as string
Dim c As Control

For each c In parent.Controls
If c.GetType() is GetType(system.web.ui.webcontrols.Label)
Then
varxml = CType(c,system.web.ui.webcontrols.Label).text
CType(c,system.web.ui.webcontrols.Label).text =
XmlLang1.GetString(varxml)

End If

Next
End SubI do something very similar with all labels on a page (though I only use c#
so the vb code is difficult for me to follow!). May I ask what actually
happens when you run this ? My first thought is that you must make the
routine recursive by calling itself on each sub-control within each top
level control on the page.

"Giovane Calabrese" <giovanectba@.brturbo.com> wrote in message
news:080e01c3c09f$55df5aa0$a401280a@.phx.gbl...
> ( aspx + vb )
> hi everyone !
> I really need make that function work !
> im brazilian , and i want to make a multilanguage system ,
> that function above must look at all ASPX take the labels
> ID and send as a parameter
> ,... so Please , help me ,.. cause it doest work !
> '------------------
> -----
> ' LOAD PAGE
> '------------------
> -----
> Private Sub Page_Load(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles MyBase.Load
> TraduzLbl(me)
> end sub
> Sub TraduzLbl(byval parent As Control)
> Dim XmlLang1 as new XmlLang
> Dim varxml as string
> Dim c As Control
> For each c In parent.Controls
> If c.GetType() is GetType(system.web.ui.webcontrols.Label)
> Then
> varxml = CType(c,system.web.ui.webcontrols.Label).text
> CType(c,system.web.ui.webcontrols.Label).text =
> XmlLang1.GetString(varxml)
> End If
> Next
> End Sub
ok. im try to make a multilanguage system based on that
tutorial :

http://www.123aspx.com/redir.aspx?res=29112

in my aspx pages all text are in labels , and i want to
take the name labels ( in one loop ) and for each label
take on the XML document the right(in the right language)
Value (text).

Above you can see what im doing , it works , however im
trying to make a function that look at all aspx and when
found a LABEL , take the value ( text) from one xml
document like the function in the end of this document.
************************************************** ********

I have created an object that will retrieve the correct
data from an XML file. The code in C# is displayed below.
----------------
using System;
using System.Xml;

namespace diffudessnet
{
public class XmlLang
{
protected XmlDataDocument X;
protected String Lang;

public XmlLang(String FileName,String
Language)
{
String Name
= "http://localhost/myapp/xml/"+ FileName;
X = new XmlDataDocument();
X.Load(Name);
Lang = Language;
}

public XmlLang(String FileName)
{
String Name
= "http://localhost/myapp/xml/"+ FileName;
X = new XmlDataDocument();
X.Load(Name);
Lang = "N";
}

public String GetString(String Name)
{
XmlNode node;
node = X.SelectSingleNode
("//main/language[@.id='" +Lang + "']/" + Name);
if (node == null) return "";
else
{
string value =
node.InnerXml.ToString();
return value;
}
}
}
}

----------------

This object has three methods:

XmlLang::XmlLang(String FileName, String Language)
XmlLang::XmlLang(String FileName)
String XmlLang::GetString(String Name)
To start, we will assume all XML documents are in the same
directory. In this way, they can be made inaccessible to
all users. The path of this directory is hardcoded in the
source of the object. A good alternative is using the
ConfigurationSettings.AppSettings method and saving all
values in the web.config file.

In the first version of the constructor, the name of the
XML file and the selected language are passed to the
constructor. If you want to select a name for the
document, it might be useful to select the same name as
you aspx file. The language parameter is a simple string.
Possible values are "N" for Dutch, "F" for French, "E" for
English, . The format of the XML document will be
discussed later.

The second version of the constructor will automatically
select the Dutch version of the texts. This option is very
handy if you only want to use the Dutch version, and other
languages are only planned for the future.

The method GetString(String Name) will retrieve the text
belonging to the node named Name from the XML file. All
text items in the XML document are marked by keywords. The
value of a keyword is the word in the specified language.
--------------
XML Document
<?xmlversion="1.0"encoding="utf-8"?>
<main>
< language id ="N">
<name>Naam</ name>
<number>Nummer</number>
<street>Straat</street>
<country>Land</country>
</ language >
< language id ="E">
<name>Name</name>
<number>Number</number>
<street>Street</street>
<country>Country</country>
</language>
<languageid="F">
<name>Nom</name>
<number>Nummro</number>
<street>Rue</street>
<country>Pays</country>
</language>
</main>


Different languages are separated by the <language
id="languageid" /> tags. The languageid attribute should
be passed to the constructor of the class.

Using the class
Using the object is pretty straightforward. You create a
new instance of the object in the OnInit(.) member
function of your page object. Suppose we have a page
called client.aspx containing client data. The name of the
codebehind file is client.aspx.cs. To make things simple,
we name the xml file client.xml.

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);

XmlLang Lang = new XmlLang("client.xml",Session
["LANGUAGE"].ToString());

this.NameLabel.Text = Lang.GetString("name");

this.StreetLabel.Text = Lang.GetString("street");

this.CountryLabel.Text = Lang.GetString("country");
}


Instead of hard-coding all static text in client.aspx, we
use labels as a replacement. In the OnInit member
function, these labels are filled with the right contents,
depending on the selected language. In this example, the
chosen language is stored in a session variable : Session
["LANGUAGE"]. The method as it is mentioned also allows
you to change column headers from a datagrid object.
************************************************** ********

>--Original Message--
>I do something very similar with all labels on a page
(though I only use c#
>so the vb code is difficult for me to follow!). May I ask
what actually
>happens when you run this ? My first thought is that you
must make the
>routine recursive by calling itself on each sub-control
within each top
>level control on the page.
>"Giovane Calabrese" <giovanectba@.brturbo.com> wrote in
message
>news:080e01c3c09f$55df5aa0$a401280a@.phx.gbl...
>> ( aspx + vb )
>> hi everyone !
>> I really need make that function work !
>> im brazilian , and i want to make a multilanguage
system ,
>> that function above must look at all ASPX take the
labels
>> ID and send as a parameter
>> ,... so Please , help me ,.. cause it doest work !
>>
>> '-----------------
--
>> -----
>> ' LOAD PAGE
>> '-----------------
--
>> -----
>> Private Sub Page_Load(ByVal sender As System.Object,
ByVal
>> e As System.EventArgs) Handles MyBase.Load
>> TraduzLbl(me)
>>
>> end sub
>>
>> Sub TraduzLbl(byval parent As Control)
>> Dim XmlLang1 as new XmlLang
>> Dim varxml as string
>> Dim c As Control
>>
>> For each c In parent.Controls
>> If c.GetType() is GetType
(system.web.ui.webcontrols.Label)
>> Then
>> varxml = CType(c,system.web.ui.webcontrols.Label).text
>> CType(c,system.web.ui.webcontrols.Label).text =
>> XmlLang1.GetString(varxml)
>>
>> End If
>>
>> Next
>> End Sub
>
>.

Taking a value from a dataset

I trying to get a single values from a dataset however I keep getting the following error please help

 Function get_poll_questions() As System.Data.DataSet

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=db\database.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT top 1 * FROM tbl_poll_questions ORDER BY pol_question, rnd(pol_ID)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0)("pol_question").ToString()

return strTesting

End Function

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 116:
Line 117:
Line 118: strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0)("pol_question").ToString()
Line 119:
Line 120: return strTesting

Many thanks in advanceMake sure that the SQL has returned any data. Also make sure that pol_question is the correct name of the column.
Also, I havent seen it done like this:

strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0)("pol_question").ToString()

Try this instead:

strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0).items("pol_question").ToString()

Also, since you are doing this:
dataAdapter.Fill(dataSet)

and not giving a table name...the table is not named "tbl_poll_questions". Rather, it is named just "table" or you could use the index of 0, like:

strTESTING = DataSet.Tables(0).Rows(0).items("pol_question").ToString()

In order to use that table name you would have to do:
dataAdapter.Fill(dataSet,"tbl_pol_questions")

MajorCats

Tuesday, March 13, 2012

targeting a response.write to a section of a web page

I have a function that calls:

response.Write("<a href='www.yadda.com >Hello</a><br />")

multiple times, creating hyperlinks like so:

Hello
Hello
Hello
Hello
Hello
Hello

Anyway, I want the values above to be put in a specific location of my
web page (inside a table cell), instead of the top, which pushes all my
content down.

Basically, I am using xquery in a search field to go through an xml
document that contains my web site navigation info, returning a url
attribute. I have the url string from the xml doc converted to a
hyperlink using the code above.

Any suggestions are appreciated.Can you drop label members where you want the links and just add this
code to your method?

label.Text = "<a href='www.yadda.com'>Hello</a>";

Hope this helps.
I ended up hiding a table within the table and appended rows and cells
with the urls.

for each book in nodeList
Dim tempRow As New TableRow()
Dim tempCell As New TableCell()
tempCell.Text = "<a class='HoverStyle' href="http://links.10026.com/?link= &
book.Attributes("url").Value & " target='_blank' a>" &
book.Attributes("title").Value & "</a>"
tempRow.Cells.Add(tempCell)
tblSearchResults.Rows.Add(tempRow)
next

thanks.
simple solution...
1) Make the table Cell Server control . <td id="cell1" runat="server"
2) keep adding all links to the cell
cell1.InnerHtml += "<a href='www.yadda.com >Hello</a><br />"

better solution.. this way u will have better control on the layout of
links
1) Make the table a Server control . <table id="table1" runat="server"
2) keep adding rows HtmlTableRow and HtmlTableCell objects to the table
for each link

targeting a response.write to a section of a web page

I have a function that calls:
response.Write("<a href='www.yadda.com >Hello</a><br />")
multiple times, creating hyperlinks like so:
Hello
Hello
Hello
Hello
Hello
Hello
Anyway, I want the values above to be put in a specific location of my
web page (inside a table cell), instead of the top, which pushes all my
content down.
Basically, I am using xquery in a search field to go through an xml
document that contains my web site navigation info, returning a url
attribute. I have the url string from the xml doc converted to a
hyperlink using the code above.
Any suggestions are appreciated.I ended up hiding a table within the table and appended rows and cells
with the urls.
for each book in nodeList
Dim tempRow As New TableRow()
Dim tempCell As New TableCell()
tempCell.Text = "<a class='HoverStyle' href="http://links.10026.com/?link= &
book.Attributes("url").Value & " target='_blank' a>" &
book.Attributes("title").Value & "</a>"
tempRow.Cells.Add(tempCell)
tblSearchResults.Rows.Add(tempRow)
next
thanks.
simple solution...
1) Make the table Cell Server control . <td id="cell1" runat="server"
2) keep adding all links to the cell
cell1.InnerHtml += "<a href='www.yadda.com >Hello</a><br />"
better solution.. this way u will have better control on the layout of
links
1) Make the table a Server control . <table id="table1" runat="server"
2) keep adding rows HtmlTableRow and HtmlTableCell objects to the table
for each link