No, you need to connect to the network before. Otherwise you can't expect the network to allow you to communicate through it. For detecting a captive portal you (the client device) need to access a domain within the network, which collides with the above. Detecting a captive portal in principle works as follows:
Connect to network
Try to open a specific webpage (this website is specific for a manufacturer, e.g. apple devices try to connect to http://captive.apple.com)
a) no response or an error is received, the device assumes that there is no internet connection
b) the expected response is received (
Success in case of apple), the device assumes that it has internet connection
c) a response is received which is different from what the device expected, it opens the response in a captive portal
The most important thing to make clear is, that it's the device itself that opens the captive portal after using the above heuristic. All the network can do to force the captive portal on the client device is to provide it with a response that the device did not expect, but it's up to the device to "detect" the captive portal. This whole captive portal story is just a hacky technique, rather than a defined standard.