I'm in a desperation to get this code done and i was able to get checkbox ID to loop but i dont know why i can't get ImageButton ID to loop
So basically this is what i'm trying to achieve
i need looping of ImageButton1.ImageUrl, ImageButton2, ImageButton3.ImageUrl,............, ImageButton48.ImageUrl
The code below is what i'm trying to achieve and i really need help here to get it working without writing the code below over 48 times...
If LaneAvai03.Checked ="True"Then
ImageButton3.ImageUrl ="~/Interface/Yes.gif"
Else
ImageButton3.ImageUrl ="~/Interface/No.gif"
ImageButton3.Enabled =False
EndIf
check out this code sample at ASPNet101.com:
http://www.aspnet101.com/aspnet101/aspnet/codesample.aspx?code=gvcolumnsvisibility
It's not exactly what you want, but it does address similarly numbered buttons (with only the number changing in the name)
I came to realize that my MasterPage has been causing me a lot of problem.... i tried the coding on my project it doesn't work but i tried on a new one it works perfectly and the coding are identical
Basically why my Master Page is affecting and giving me all this problem... below are the error shown...
Object reference not set to an instance of an object.
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 7: Line 8: Dim btn As ImageButton = CType(FindControl("ImageButton" & num), ImageButton)Line 9: btn.ImageUrl = "Yes.gif"Line 10: NextLine 11: End SubSource File:I:\Assignment\Double Module Project\Coding\OCSS\Test2.aspx.vb Line:9
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] Test2.Page_Load(Object sender, EventArgs e) in I:\Assignment\Double Module Project\Coding\OCSS\Test2.aspx.vb:9 System.Web.UI.Control.OnLoad(EventArgs e) +80 System.Web.UI.Control.LoadRecursive() +49 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3744
You have no path for the image - ASP.net doesn't know where to get "yes.gif"
I thought it's the image path as well but i keep trying but it just doesn't work
I realize that it will work if i didn't use MasterPage but once i use MasterPage the code just doesn't work...
I realize another thing is that if u put ImageButton1.ImageUrl = "Yes.gif" it will work perfectly even within MasterPage but the coding below just somehow won't work... Is there anything i done wrong on the coding below?
For numAsInteger = 1To 3Dim btnAs ImageButton =CType(FindControl("ImageButton" & num), ImageButton)
'ImageButton1.ImageUrl = "WeddingGown.jpg"
btn.ImageUrl ="WeddingGown.jpg"
Next
0 comments:
Post a Comment