|
That is in fact what I ended up doing as a workaround. However, I'm still interested in whether this is possible, as I encounter this situation periodically. I have used FindControl("stringname") for the times when I'm specifying a control, but there are times when evaluating a string as code might be useful; perhaps even composing an entire statement dynamically... but thank-you for responding with a workaround suggestion.
|
|
|
|
|
Hi ,
please i learnt something called VIEWSTATE & i didn't understand it well
what i want to know is what is the role of that viewstate ?? why we use it ? & when ?
thank you
try to be good if you can't be the best
|
|
|
|
|
Hi,
When a control is created dynamically at run time, some information about the control is stored in the view state that is rendered with the page. When the page is posted back to the server, however, non-dynamic controls (those defined on the page) are instantiated in the Page.Init event and view state information is loaded before the dynamic controls can be recreated (generally in the Page_Load handler). Effectively, before the dynamic controls are recreated, view state is temporarily out of sync with the page's controls. After the Page_Load event has run, but before control event handling methods are called, the remaining view state information is loaded into the dynamically created controls.
In most scenarios, this view state processing model works fine. Typically, you add dynamic controls to the end of a container's collection of controls. The view state information stored for the dynamic controls is therefore extra information at the end of the view state structure for the appropriate container, and the page can ignore it until after the controls are created.
However, view state information about dynamically created controls can be a problem in two scenarios:
If you insert dynamic controls between existing controls.
If you insert controls dynamically and then reinsert them during a round trip, but with different values.
If you insert dynamic controls between existing controls, the dynamic control's view state information is inserted into the corresponding location of the view state structure. When the page is posted and the view state is loaded, the dynamic control does not yet exist; therefore, the extra information in view state does not correspond to the right control. The result is usually an error indicating an invalid cast.
Hope u understood the y we require ViewState.
|
|
|
|
|
thank you man thank you very much , i just didn't understand what you mean by dynamic controls & non-dynamic ones
well i think i have more to learn before learning abt view states
try to be good if you can't be the best
|
|
|
|
|
Hi,
U can just go to the link and read I hope this will surly help u as I read this to understood Viewstate.I new to .NET but it helped me a lot.
http://www.dotnetjohn.com/PrintFriend.aspx?articleid=71
Regards.
|
|
|
|
|
thank you
try to be good if you can't be the best
|
|
|
|
|
I'm using the REPLACE property of the stringbuilder class to change the font size within a "FONT" tag, however the string that I'm referencing contains apostrophes around the number, which obviously causes problems.
Here's my code:
-----------------------------------------
Dim strHTML As System.Text.StringBuilder = New System.Text.StringBuilder()
strHTML.Replace("<font size="3">", "<font size="20">")
-------------------------------------------
What can I do so that I can still replace the "3" with a "20" without causing the program to crash due to the apostrophes?
Thanks in advance.
-Goalie35
-- modified at 17:31 Monday 19th June, 2006
|
|
|
|
|
You need to escape the double quote with a backslash.
strHTML.Replace("", "")
|
|
|
|
|
Use double quotes to put a quote in a string:
strHTML.Replace("<font size=""3"">", "<font size=""20"">")
---
b { font-weight: normal; }
|
|
|
|
|
Hello All,
I have a datagrid control on webpart, in which I am displaying two out of six columns from a dataset. When somebody click on one row, I want to display all six values for that row on the same webpart without postback. i made this datagrid clickable. i m passing value using the following code.
public void dgSpeakerEvents_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.DataItem!=null)
{
e.Item.Attributes.Add("onmouseover","this.style.cursor='hand'");
e.Item.Attributes.Add("onclick","ShowDetails('"+
DataBinder.Eval(e.Item.DataItem, "TOPIC_NM").ToString()+ "','"+
DataBinder.Eval(e.Item.DataItem, "CITY").ToString()+ "','"+
DataBinder.Eval(e.Item.DataItem, "STATE").ToString()+ "');");
//e.Item.Attributes.Add("onmouseout", "HideTooltip();");
}
}
but when i clicked on datagrid, it shows an error: object expected. i checked in the html source code generated by the browser, values passing correctly.
my javascript function is :
function detail()
{
function ShowTooltip(name,city,state)
{
document.getElementById('td0').innerText=name;
document.getElementById('td1').innerText=city;
document.getElementById('td2').innerText=state;
X=event.clientX+document.body.scrollLeft;
Y= event.clientY + document.body.scrollTop + 10;
Popup.style.display='block';
Popup.style.left = X;
Popup.style.top = Y;
}
}
function HideTooltip()
{
Popup.style.display='none';
}
If any body can suggest me with good example.Thanks.
Dhruvil
-- modified at 16:53 Monday 19th June, 2006
|
|
|
|
|
Hi
Sorry to bother you guys but this is driving me nuts. I'm trying to retrieve a list of email addresses from a database, and send an email to all those addresses. For testing purposes, the database contains 1 address, mine. Code below (with senstivie bits *** out)
Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
If Page.IsValid Then
Dim strSQL As String
Dim MyConn As Data.SqlClient.SqlConnection
MyConn = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Dim strBody As String
Dim Msg As New System.Net.Mail.MailMessage
Dim MailObj As New System.Net.Mail.SmtpClient()
'retrieve list of email address,IDs etc
strSQL = "Select * From vwNewsLetterList"
Dim objDR As Data.SqlClient.SqlDataReader
Dim Cmd As New Data.SqlClient.SqlCommand(strSQL, MyConn)
MyConn.Open()
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
'loop thru data, construct the message and send it
While objDR.Read()
strBody = txtMessage.Text
Msg.IsBodyHtml = True
Msg.Subject = "Test email"
MailObj.Host = "mail.*****.net"
Msg.From = New System.Net.Mail.MailAddress("*@*.net")
Msg.To.Add(New System.Net.Mail.MailAddress(objDR("Email")))
Msg.Body = strBody
MailObj.Send(Msg)
End While
MyConn.Close()
End If
End Sub
The code excutes with no errors, but... immediately afterwards I see my virus scanner going, and when I check my mail I get an "Undelivered Mail Returned to Sender" message from my virus checker, with the following info:
I'm sorry to have to inform you that the message returned
below could not be delivered to one or more destinations.
-------------------------------------------------------------------
*******@*****.com: sorry, that domain isn't allowed to be relayed thru this MTA (#5.7.1)
-------------------------------------------------------------------
Your e-mail message is being returned to you in the next part of this
message. Try to send the message again.
It seems as if the code is trying to send the message through my personal email server rather than the smpt client specified in the code. What am I doing wrong? Oh, and by the way... if I use "traditonal" ASP and specifiy this Smtp client, it works perfectly.
|
|
|
|
|
try this
Try
Dim smtpserver As Web.Mail.SmtpMail
Dim mesg As New Web.Mail.MailMessage
smtpserver.SmtpServer=strsmtpserver
mesg.From = mailFrom
mesg.To = mailto
mesg.Subject = subj
mesg.Body = messg
smtpserver.Send(mesg)
i = "Mail Sent"
Catch
i = "Failed to send Mail"
End Try
Remember that ur mail id should be a part of the smtp server e.g if ur id is xzy@yahoo.com then smtp server should be of yahoo else u will get the relay error message
|
|
|
|
|
OK, it's sorted - and I didn't have to change any of the code. It turns out my webhost wants the SMTP server bit called "localhost". Thats all that was required. Thank you for the reply though, smita_roy.
|
|
|
|
|
hey ,
well i'm a beginner in ASP.Net & i've leanrt something abt the latest ASP.Net 2.0 & i wanna walk to be an expert one day
i just tried to build ma first web page that enter to the database but i had a problem
ma web page doesn't shown , i see in the browser an other page that tells me that i can't open this database because it is already opened & stuffs & it gives me thecode i wrote in the maapp.aspx.vb & it stops in the first line
Connection.Open
i hope you understood me i really need that help i wanna make it work thank you very much
try to be good if you can't be the best
|
|
|
|
|
most likely you have a invalid connection string to your database. make sure your premissions to the db are set correctly.
|
|
|
|
|
nop , everything is correct i think something in the configuration of the IIS server or something please i really wanna make this sh*t work so can you send me something or write me some steps to follow to get the result wanted ??
thank you very much
try to be good if you can't be the best
|
|
|
|
|
Hi,
I made a project with ASP.NET (C#) and SQL Server Express 2005. After I finished the project in my PC, I wanted to upload the project in the remote server. In my project folder, I had App_Data folder. So, I also created App_Data folder in my remote server. Then I transferred the .MDF file in from my App_Data folder to remote App_Data folder. My Reomote server (Lunarpages) has SQL Server 2005. My Web.Cnfig contains the connection string like this,
(add name="rBMain" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\rBOnline.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient")
But I was given error saying , Remote connection is not allowed. I am new in ASp.NET, would anyone please help me.
Thanks and regards
EMRAN
-- modified at 15:09 Monday 19th June, 2006
|
|
|
|
|
emran834 wrote: My Reomote server (Lunarpages)
probably doesn't use integrated security. Ask there tech support
|
|
|
|
|
So I have a Web.sitemap file like this:
<br />
<siteMapNode url="Default.aspx" title="Home" description="Start Page"><br />
<siteMapNode url="Profile/Default.aspx" title="Profile Settings" description="Profile Stuff"><br />
<siteMapNode url="Profile/Register.aspx" title="Register" description="Register your account"/><br />
<siteMapNode url="Profile/RetrievePassword.aspx" title="Retrieve Password" description="Retrieve your password"/> <br />
<siteMapNode url="Profile/EditProfile.aspx" title="Edit Profile" description="Edit your profile" roles="User"/><br />
<siteMapNode url="Profile/ChangePassword.aspx" title="Change Password" description="Change your password" roles="User"/><br />
</siteMapNode><br />
Note the last two options have Roles="User". As I understand it that means when a Menu control is configured to get its data from SiteMap provider it will only display those options to users in the role of "User". Also, I understand it that unauthorized users have no roles. That being said when I navigate to the page with that menu on it without being authenticated all 4 nodes show up in the menu.
Now just to test I put this code in the codebehind:
this.Label1.Text = Context.User.IsInRole("User") ? "true" : "false";
And it does indeed print false on the page (and true when I do log in) so I know for a fact that as an anonymous user I am not in the "user" role. What am I doing wrong here?
-- modified at 14:51 Monday 19th June, 2006
EDIT: Fixed < and >
|
|
|
|
|
|
Ok I read this page and added this to Web.config
<br />
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true"><br />
<providers><br />
<add name="XmlSiteMapProvider"<br />
description="Default SiteMap provider."<br />
type="System.Web.XmlSiteMapProvider "<br />
siteMapFile="Web.sitemap"<br />
securityTrimmingEnabled="true" /><br />
</providers><br />
</siteMap><br />
Set roles="User" in one of the siteMapNode's and nothing changed. So I really don't know whats wrong here.
|
|
|
|
|
|
I have click event on button. It works fine after clicking the button twice it doesn't do anything on first click. After clicking it aging it works fine.
Any idea why???
Thanks
|
|
|
|
|
Whats the code in the Button_Click event handler?
Also do you already have focus on the window for the first click?
|
|
|
|
|
button is not dead ... when i click it first time it posts back ... goes to page load and comes back and doesn't do anything when i click it again it goes to the page load and then goes to event function and works fine ... but i don't why it doesn't go to click event on first click
Thanks
|
|
|
|